Re: Clarification on "live NodeList"

Boris Zbarsky wrote:
> Andrew Fedoniouk wrote:
>> Do you know any existing code that relies on liveness of NodeLists?
> 
> I don't have pointers offhand, but sites out there do things like:
> 
> var list = document.getElementsByTagName("something");
> while (list.length) {
>   list[0].parentNode.removeChild(list[0]);
> }

One pointer:

http://archive.fantasysports.yahoo.com/archive/nba/2006/186942/rosters?mid=12&stat1=S&stat2=S_2006&sort=10

YAHOO.html.clearChildNodes says effectively:

         if(nodeType != null && nodeType != 'undefined') {
             var remNodes = atNode.getElementsByTagName(nodeType);
         }
         else {
             var remNodes = atNode.childNodes;
         }
         var nodeLim = remNodes.length;
         for(var x = 0; x<nodeLim; x++) {
             atNode.removeChild(remNodes[0]);
         }

-- 
Philip Taylor
pjt47@cam.ac.uk

Received on Friday, 10 July 2009 18:33:05 UTC