Doist / ICE

The Lightweight JavaScript library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

$$() return value format

janogarcia opened this issue · comments

This should be valid ICE, but it actually doesn't work:
$addClass($$('div.class'), 'new-class');

On the other hand, this works as expected:
$addClass($all('div', 'class'), 'new-class');

This is caused by $$() and $all() not using the same result format.

The deprecated $all() method returns an array, via the $arrayForce helper.
return ICE.$arrayForce(parent.querySelectorAll(selector));

ICE/ICE.js

Line 355 in 8391b61

class_elements = ICE.$arrayForce(parent.querySelectorAll(selector));

While the newer $$() method returns a NodeList object, and thus failing when that result is passed by $addClass, $setStyle and the like to the $map method.
return document.querySelectorAll(selector);

ICE/ICE.js

Line 337 in 8391b61

return document.querySelectorAll(selector);

Fixed in latest commit