Re: [whatwg] Proposal: Adding methods like getElementById and getElementsByTagName to DocumentFragments

On Fri, Oct 18, 2013 at 10:56 PM, Boris Zbarsky <bzbarsky@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
escape rules.

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?


-- 
http://annevankesteren.nl/

Received on Tuesday, 22 October 2013 11:00:30 UTC