[dojo-contributors] DOM NodeType values not in 0.9

Brad Neuberg paperairplane at gmail.com
Sat Jun 9 21:13:21 EDT 2007


>
> > Using these make for much more readable code when doing HTML DOM
> > manipulation. So you might have the following:
> >
> > var top = dojo.byId("top");
> > for (var i = 0; i < top.childNodes.length; i++){
> >       var currentNode = top.childNodes[i];
> >       if (currentNode.nodeType == dojo.dom.ELEMENT_NODE &&
> >               currentNode.className == "status"){
> >               top.removeChild(currentNode);
> >       }
> > }
>
> That whole thing should be re-written as:
>
>         dojo.query("#top >").orphan(".status");

Whow, that's a whole new world there :) Can you break that down a bit?
I see that you used a CSS selector to find the node to work with...
then, what's orphan()? Is it recommended that Dojo framework code now
use dojo.query() instead of standard DOM code?

Brad

>
> > rather than just if(currentNode.nodeType == 1)
> >
> > It was a bug in the browsers not to include the standard DOM element
> > node values given by nodeType; they are correctly predefined in
> > Mozilla but not Internet Explorer, which was a bug and which is why
> > everyone uses the numbers in their code versus what the standard said
> > to do. Here are Mozilla's predefined values in the global object
> > Node: http://developer.mozilla.org/en/docs/DOM:element.nodeType ,
> > which allowed you to just say Node.ELEMENT_NODE rather than '1'.
> >
> > Can we put these values somewhere in the core?
>
> Nope.
>
> Regards
>
> --
> Alex Russell
> alex at sitepen.com     A99F 8785 F491 D5FD 04D7 ACD9 4158 FFDF 2894 6876
> alex at dojotoolkit.org BE03 E88D EABB 2116 CC49 8259 CF78 E242 59C3 9723
>
>



More information about the dojo-contributors mailing list