Re: Clarification on "live NodeList"

Philip Taylor wrote:
> 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]);
>         }
>
I am not sure this piece will run at all.
remNodes will not be seen outside blocks where they declared: { var 
remNodes = whatever }

My condolences to YAHOO.html namespace.

But this counts as a proof that it might be some code in the wild that 
rely on this.
Non-effective at its best but now I know why batteries on mobile devices 
are dying on AJAX sites.

--
Andrew Fedoniouk.

http://terrainformatica.com

Received on Friday, 10 July 2009 22:53:30 UTC