[whatwg] Proposal: Adding methods like getElementById and getElementsByTagName to DocumentFragments
Anne van Kesteren
annevk at annevk.nl
Tue Oct 22 04:00:00 PDT 2013
On Fri, Oct 18, 2013 at 10:56 PM, Boris Zbarsky <bzbarsky at mit.edu> wrote:
> So it looks to me like in practice Element.getElementById could be quite a
> bit faster than the equivalent querySelector call, for both the in-tree case
> (where both can avoid walking the tree) and the out-of-tree case (where both
> need to walk the tree).
> Food for thought.
So do you think we should add getElementById() to ParentNode in DOM?
It seems the advantages are that we can optimize it better than
querySelector() because there is no selector parsing. And because
there is no selector parsing, you can simply pass the value of an
element's id attribute rather than escaping said value using CSS
What it seems we lack is a clear need for either, but if the cost of
implementing it is low, maybe it's worth it?
More information about the whatwg