rgrove / jquery-yui3-rosetta-stone

A guide to idioms in YUI 3 and jQuery.
BSD 3-Clause "New" or "Revised" License
65 stars 20 forks source link

Array vs NodeList #1

Closed einarq closed 13 years ago

einarq commented 13 years ago

YUI 3.3 added the Array 1.5 methods to NodeList, such as concat. This should probably be mentioned. Also I think you should probably recommend using Y.NodeList.getDomNodes instead of the private ._nodes property, but that is just my personal opinion...

rgrove commented 13 years ago

Thanks for reminding me about the new Array methods on NodeList. Definitely worth mentioning.

You're probably right about ._nodes vs. NodeList.getDOMNodes() from the standpoint that the Rosetta Stone should only recommend best practices.

My personal stance is that ._nodes should just be made (officially) public. It's extremely unlikely that it's going to need to change for any reason in the 3.x code line, and NodeList.getDOMNodes() is just unnecessary overhead for getting to ._nodes. We'll see what happens.

rgrove commented 13 years ago

YUI: Update various examples to use the new 3.3.0 NodeList array methods. [Closed by 849e4b115857e84ce5e54c1f1d3e2050cb12222a]

einarq commented 13 years ago

That was fast! Exellent, thanks. I agree that ._nodes (and ._node) is probably used a lot and hence might as well be made public. The irony is that if they were ever made public, they should not have the _ prefix, and hence all the code that uses those properties would have to be updated. Unless you keep the name of course, but that would probably be a bit confusing with regards to naming standards. Perhaps you could add a dom() method (or some other name) for more easy access to the underlying dom nodes in a Node or NodeList?