opal / opal-browser

Browser support for Opal.
MIT License
115 stars 36 forks source link

Counter intuitive behavior of #css, #css_at etc. when applied to NodeSet #18

Closed lorefnon closed 10 years ago

lorefnon commented 10 years ago

I see that in https://github.com/opal/opal-browser/blob/master/opal/browser/dom/node_set.rb#L17-L36 , methods applied to NodeSet are transparently applied to each dom node in set iteratively, with the return value always being the original set.

However this may be counter-intuitive if a user attempts to call finder methods like css or css_at on a NodeSet as then the return value will simply be the original set rather than aggregation of selections over each node in the set, as may be expected due to familiarity with popular js libraries like jquery.

I would suggest defining finder methods for NodeSet which aggregate the result of running the corresponding methods on each item in set.

I can work on a fix if there is consensus regarding changing this behavior.

meh commented 10 years ago

I agree, although there are NodeSet#search and NodeSet#filter.

meh commented 10 years ago

Fixed on master.