Re: Allow to return same NodeList object for queries like getElementsByTagName, getElementsByClassName and getElementsByName

On Feb 12, 2010, at 7:53 AM, Maciej Stachowiak wrote:

>
>>
>> Also, what happens with garbage collection? Say some isolated piece  
>> of code does:
>>
>> x = document.getElementsByTagName("x")
>> x.p = 2
>>
>> ... and then later on some other piece of code does:
>>
>> y = document.getElementsByTagName("x")
>> w("p" in y)
>>
>> Depending on whether or not x got garbage collected you would get a  
>> different result.
>
> Indeed, that is what I cited as the one observable side effect.  
> (Except the other piece of code doesn't have to happen later, it  
> could be the very next line.)
>
> To the best of my knowledge, it is not common practice to add custom  
> properties to NodeLists, as opposed to Nodes, especially Elements,  
> where it is fairly common practice. The fact that you can never be  
> guaranteed to get the same NodeList back means

I meant to say: "The fact that you can never be guaranteed to get the  
same NodeList back means that doing this to NodeLists is of limited  
utility. Usually authors use custom properties to store additional  
data for later retrieval."

Regards,
Maciej

Received on Friday, 12 February 2010 15:57:30 UTC