Re: QSA, the problem with ":scope", and naming

On 10/19/11 11:17 AM, Boris Zbarsky wrote:
> 4) Mapping Sizzle("#id") with document a context to
> getElementById("id"). This isn't a valid optimization for querySelector
> because there can be multiple elements with the same id;

And just as a note, since someone asked me off-list how this can 
possibly be true...  Given this markup:

     <div id="x">
       <div id="y"></div>
       <div id="y"></div>
     </div>

calling

   jQuery.find("#y")

returns an array with one element in it while calling

   jQuery.find("#y", document.getElementById("x"))

returns an array with two elements.  I have no idea whether this is 
purposeful behavior or just a bug in Sizzle brought on by the 
optimization listed above.

-Boris

Received on Wednesday, 19 October 2011 16:30:44 UTC