DescriptionOptimized querySelector(All) when selector contains #id.
There existed an optimization that did an element lookup for an id if the
leftmost part of the selector was an id selector. Without this change, these
queries would do an id lookup:
querySelector("#id"), querySelector("#id.class")
while these wouldn't:
querySelector(".class#id"), querySelector("[name=x]#id")
This change modifies the element lookup to include the latter two.
More importantly, it also extends the optimization for id selectors to limit
traversal of the dom-tree to the sub-tree rooted at the element with an id
matching the rightmost id selector in the whole selector. For id selectors
appearing left of adjacent combinators, the traversal needs to be rooted at
the parent of the element with the given id.
Examples:
querySelector("#id span") - traversal from the id element.
querySelector("#id + div span") - traversal from the parent of the id element.
This fix should make this:
querySelector("#id span")
as fast as:
getElementById("id").querySelector("span")
BUG=240188
Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=150417
Patch Set 1 #
Total comments: 5
Patch Set 2 : Fixed review issues. #
Total comments: 2
Patch Set 3 : Fixed review issues in Patch Set 2 #
Messages
Total messages: 11 (0 generated)
|