W3C home > Mailing lists > Public > whatwg@whatwg.org > June 2013

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

From: Zirak A <zirak@mail.com>
Date: Fri, 28 Jun 2013 17:28:57 -0400
Message-ID: <20130628212857.262740@gmx.com>
To: "Tab Atkins Jr." <jackalmage@gmail.com>
Cc: WHATWG <whatwg@lists.whatwg.org>
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.

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.

----- Original Message -----
From: Tab Atkins Jr.
Sent: 06/28/13 09:06 PM
To: Zirak A
Subject: Re: [whatwg] Proposal: Adding methods like getElementById and getElementsByTagName to DocumentFragments
 On Fri, Jun 28, 2013 at 1:19 PM, Zirak A <zirak@mail.com> wrote:
> Currently, a DocumentFragment only inherits from Node, and thus loses methods like getElementById. However, the Selector API (http://www.w3.org/TR/selectors-api/) defines querySelector and querySelectorAll on document fragments.
> My proposal is to add getElementById (which makes sense, as the document fragment is a root node), getElementsByTagName (and its namespace-sensitive version), getElementsByClassName and getElementsByName - in short, all of the general selection methods available on the Document.

Given that you have querySelector, why would you want the other
functions? getElementById("foo") is just querySelector("#foo"),
getElementsByTagName("foo") is just querySelectorAll("foo"), etc.

~TJ 
Received on Friday, 28 June 2013 21:29:22 UTC

This archive was generated by hypermail 2.3.1 : Monday, 13 April 2015 23:09:22 UTC