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

Zirak A zirak at mail.com
Fri Jun 28 16:45:11 PDT 2013


My intention wasn't for this to be an argument whether the selectors API make
anything before them obsolete. The intention was to make the API more
consistent - if documents have a getElementById method, so should document
fragments.
I acknowledge that selectors let you write more complex queries, and that some
developers prefer them. However, others (like me) prefer using the "older"
methods like getElementById. As said, this is an attempt to make the API more
consistent, given that we already have methods like getElementById.
  
----- Original Message -----
From: Tab Atkins Jr.
Sent: 06/28/13 10:51 PM
To: Zirak A
Subject: Re: [whatwg] Proposal: Adding methods like getElementById and getElementsByTagName to DocumentFragments
 On Fri, Jun 28, 2013 at 2:28 PM, Zirak A <zirak at mail.com> wrote:
> Because they may result in the same thing, but they have different semantic
> meanings. I want to get an element by its id, not run a CSS selector. I want
> to get elements by their tag names, not run a CSS selector.

There's no semantic difference between the methods. querySelector is
simply a more powerful querying function than the old DOM methods,
capable of doing everything the old methods did and much more.

> Besides my personal aversion towards selectors being in the DOM API, there's
> also the simple fact that it makes sense for document fragments to have these
> methods.

That's far from obvious, given that I don't think it makes sense to
spread those obsolete methods around any further.

~TJ 



More information about the whatwg mailing list