W3C home > Mailing lists > Public > public-webapps@w3.org > April to June 2015

Re: Why is querySelector much slower?

From: Boris Zbarsky <bzbarsky@mit.edu>
Date: Tue, 28 Apr 2015 10:58:25 -0400
Message-ID: <553FA011.10106@mit.edu>
To: Glen Huang <curvedmark@gmail.com>
CC: public-webapps <public-webapps@w3.org>
On 4/28/15 1:58 AM, Glen Huang wrote:
> Just a quick follow up question to quench my curiosity: if I do "list[1]" and no one has ever asked the list for any element, Gecko will find the first two matching elements, and store them in the list, if I then immediately do "list[0]", the first element is returned without walking the DOM (assuming there are at least two matching elements)?

Yes, exactly.

>> querySelector("foo") and getElementsByTagName("foo")[0] can return different nodes
>
> Still a bit confused regarding this. If the premise is the selector only contains characters allowed in a tag name

Then in that case I _think_ those are now equivalent, though I'd have to 
check it carefully.  They didn't use to be back when 
getElementsByTagName was defined as matching on qualified name, not 
localname...

-Boris
Received on Tuesday, 28 April 2015 14:58:58 UTC

This archive was generated by hypermail 2.3.1 : Friday, 27 October 2017 07:27:31 UTC