W3C home > Mailing lists > Public > public-webapps@w3.org > April to June 2012

Re: [webcomponents] HTML Parsing and the <template> element

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Thu, 7 Jun 2012 10:35:46 -0700
Message-ID: <CAAWBYDDEkWUvyjxCydtuzSLPmzx4QawJswXV4KQZAhuA07CD=g@mail.gmail.com>
To: Henri Sivonen <hsivonen@iki.fi>
Cc: Ian Hickson <ian@hixie.ch>, Rafael Weinstein <rafaelw@google.com>, Dimitri Glazkov <dglazkov@chromium.org>, public-webapps <public-webapps@w3.org>, Adam Barth <w3c@adambarth.com>, Erik Arvidsson <arv@google.com>, Yehuda Katz <wycats@gmail.com>
On Thu, Jun 7, 2012 at 2:45 AM, Henri Sivonen <hsivonen@iki.fi> wrote:
> On Wed, Jun 6, 2012 at 7:13 PM, Tab Atkins Jr. <jackalmage@gmail.com> wrote:
>> A call like "document.querySelectorAll('p')" doesn't *want* to get the
>> <p> inside the template.
>
> I think it's backwards to assume that querySelectorAll() works a
> particular way and that's that's not what authors want and to change
> the DOM in response.
>
> There are various solutions that don't involve drastic changes to the
> correspondence between the markup and the DOM, for example:
>
> * Invoking querySelectorAll() on a wrapper element that's known not to
> be a parent of the templates on the page.
>
> * Using a selector that fails to match elements whose ancestor chain
> contains a template element.
>
> * Introducing an API querySelectorNonTemplate(). (Don't say "All" if
> you don't mean *all*).

I gave all of these alternatives in the email you replied to. ^_^

Adding new API is a non-starter (it won't get used, and I think the
common case is "non-template"), and I already argued that expecting
authors to always get the scope right is similarly a non-starter.

Just saying that querySelector/All doesn't match elements in a
template (unless the scope is inside the template already) would work,
but it means that we have to make sure that all future similar APIs
also pay attention to this.

Pulling them out of the DOM ensures that we don't have to think about
this stuff in the future, and so can't mess it up accidentally.

~TJ
Received on Thursday, 7 June 2012 17:36:42 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:52 GMT