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

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

From: Alec Flett <alecflett@chromium.org>
Date: Thu, 7 Jun 2012 10:16:11 -0700
Message-ID: <CAHWpXeby5TY+wUTi7Bo_O99MO8ms+jjSGBueuu1mZeCC54FMfQ@mail.gmail.com>
To: Henri Sivonen <hsivonen@iki.fi>
Cc: "Tab Atkins Jr." <jackalmage@gmail.com>, 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.
You could make this argument about any assumption anyone makes anywhere
which in any way adds features.

<template> is a pretty fundamentally different use of the DOM from existing
practices and it seems like violations of existing rules are likely.

That said, is a best practice here to put <template> in the <head> if web
developers are inclined to inline the template declaration? At least then
you can rely on document.body.querySelectorAll(). That seems like the
cleanest approach from a developer's perspective and is consistent with
practices like putting embedded CSS in the <head>.


> 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*).
> Even though XML has fallen out of favor, I think violations of the DOM
> Consistency principle and features that don't work with the XHTML
> serialization should be considered huge red flags indicating faulty
> design.
> --
> Henri Sivonen
> hsivonen@iki.fi
> http://hsivonen.iki.fi/
Received on Friday, 8 June 2012 15:38:51 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 18:13:34 UTC