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

Boris Zbarsky bzbarsky at MIT.EDU
Fri Jun 28 19:01:22 PDT 2013

On 6/28/13 5:06 PM, Tab Atkins Jr. wrote:
> getElementById("foo") is just querySelector("#foo")

This is actually false.  For example, getElementById("foo:bar") is just 
querySelector("#foo\\:bar"), which is ... nonobvious.

It gets worse if you don't control the id that's passed in, because 
getElementById(arg) becomes querySelector("#"+cssEscape(arg)) where 
cssEscape is a not entirely trivial-to-write function, if you want it to 
work reliably.


More information about the whatwg mailing list