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

Tab Atkins Jr. jackalmage at gmail.com
Fri Jun 28 14:06:58 PDT 2013


On Fri, Jun 28, 2013 at 1:19 PM, Zirak A <zirak at 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



More information about the whatwg mailing list