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

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

From: Tim Streater <tim@clothears.org.uk>
Date: 28 Jun 2013 22:17 +0100
To: Zirak A <zirak@mail.com>, <whatwg@lists.whatwg.org>
Message-Id: <20130628211759.58FAB9842E7@zapata.dreamhost.com>
On 28 Jun 2013 at 21:19, 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.

I'd like to support this. I typically have an array of pointers to table bodies, and I want to search those looking for a particular row by id. Only one of the table bodies is in the DOM at any given time, and at present for a table body that is not in the DOM I have to hook it to a fragment and then do something like:

   rowPtr = fragPtr.querySelector ("#" + id);

I'd rather be able to use getElementById.

Cheers  --  Tim
Received on Friday, 28 June 2013 21:18:21 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 17:00:00 UTC