[whatwg] Proposal: Adding methods like getElementById and getElementsByTagName to DocumentFragments
bzbarsky at MIT.EDU
Tue Oct 22 20:47:31 PDT 2013
On 10/22/13 7:00 AM, Anne van Kesteren wrote:
> So do you think we should add getElementById() to ParentNode in DOM?
I actually do, yes.
> It seems the advantages are that we can optimize it better than
> querySelector() because there is no selector parsing.
This, in my mind, is a somewhat minor advantage.
> 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.
Right. More importantly, you don't have to even understand that there
are CSS escaping rules involved, which is a bigger hurdle than doing the
escaping once you've understood that part....
> What it seems we lack is a clear need for either
Where by "either" you mean lack of a need for passing without escaping
first? See above.
> but if the cost of
> implementing it is low, maybe it's worth it?
The way I see it, UAs already have to implement
SVGSVGElement.prototype.getElementById. I suspect that in practice the
same implementation can be used for any Element or DocumentFragment, so
the cost of implementing is in fact quite low.
More information about the whatwg