W3C home > Mailing lists > Public > public-html@w3.org > July 2009

Re: Clarification on "live NodeList"

From: Philip Taylor <pjt47@cam.ac.uk>
Date: Fri, 10 Jul 2009 19:32:27 +0100
Message-ID: <4A57893B.3040207@cam.ac.uk>
To: Boris Zbarsky <bzbarsky@MIT.EDU>
CC: Andrew Fedoniouk <news@terrainformatica.com>, HTML WG <public-html@w3.org>
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

This archive was generated by hypermail 2.3.1 : Thursday, 29 October 2015 10:15:48 UTC