- From: Ryosuke Niwa <rniwa@apple.com>
- Date: Fri, 18 Oct 2013 10:47:06 -0700
- To: Tim Streater <tim@clothears.org.uk>
- Cc: whatwg <whatwg@lists.whatwg.org>, Glenn Maynard <glenn@zewt.org>, Ian Hickson <ian@hixie.ch>, Boris Zbarsky <bzbarsky@mit.edu>
On Oct 18, 2013, at 5:22 AM, Tim Streater <tim@clothears.org.uk> wrote: > On 15 Oct 2013 at 01:18, Glenn Maynard <glenn@zewt.org> wrote: > >> On Thu, Oct 10, 2013 at 1:41 PM, Ian Hickson <ian@hixie.ch> wrote: > > [snip] > >>> document.getElementById(id) >>> >>> ...becomes: >>> >>> document.querySelector('#' + escapeCSSIdent(id)) >>> >>> ...which is a lot less pretty and understandable, especially when you >>> consider that many authors are actually coming from: >>> >>> document.all[id] >>> >>> ...which is briefer than either, and still self-explanatory. >>> >>> >>> I feel this is a case where we're not putting authors first, but are >>> instead putting spec purity first. > >> (Nothing about this discussion relates to "spec purity", whatever that >> means. My argument is that this function is useless legacy, and that >> proliferating it to DocumentFragment seems to be for consistency's sake >> only.) > > It's not useless legacy, it's a simple API call that does what it says. > > I have an array of table bodies, one of which I switch into the user's view by unhooking the present one from the table and appendChild-ing the one the user now wants to look at. It's irritating enough that to search one of these tBodies for an id I have to temporarily hook it to a DocumentFragment without then being forced to use an opaque API call to get the result I want. > > Personally I'd vote for it being possible to search any object for an id, never mind it having to be part of the DOM or attached to a fragment. How about: > > tbodyPtr.getElementById (id); > > That might be too radical so I'd settle for getElementById and friends being available on fragments. Then we'd have consistency. I'm fine with exposing getElementById on DocumentFragment or on ShadowRoot because it returns exactly one element. What I'm opposed to is exposing getElementsByTagName, etc... because they return a live HTMLCollection. HTMLCollection is a horrible mess, and the use of it should be discouraged as much as possible. - R. Niwa
Received on Friday, 18 October 2013 17:47:30 UTC