Re: Making <template> play nice with XML and tags-and-text

On Wed, Jul 18, 2012 at 11:29 AM, Adam Klein <adamk@chromium.org> wrote:

> On Wed, Jul 18, 2012 at 9:19 AM, Adam Barth <w3c@adambarth.com> wrote:
>
>> Inspired by a conversation with hsivonen in #whatwg, I spend some time
>> thinking about how we would design <template> for an XML world.  One idea I
>> had was to put the elements inside the template into a namespace other than
>> http://www.w3.org/1999/xhtml.
>
>
> Interesting idea! We considered something like this back before Rafael's
> initial email to WebApps but discarded it for reasons discussed below.
>
> One question about your proposal: do the contents of <template> in an HTML
> document parse as HTML or XHTML (I'm not as familiar as I should be with
> how the contents of <svg> are parsed in HTML)? For example, can I omit
> closing </p> tags?
>

We get to pick, but presumably we'd pick HTML-like parsing.


> Unlike the existing "wormhole" <template> semantics, in this approach the
>> tags-and-text inside <template> would translate into DOM as usual for XML.
>>  We'd get the "inert" behavior for free because we'd avoid defining any
>> behavior for elements in the http://www.w3.org/2012/xhtml-templatenamespace (just as no behavior is defined today).
>>
>
> This does get you inertness, but doesn't avoid querySelector matching
> elements inside <template>.
>
> Also, the elements inside <template>, though they appear to be HTML,
> wouldn't have any of the IDL attributes one might expect, e.g., <a
> href="foo"></a> would have no "href" property in JS (nor would <img> have
> src, etc). They are, perhaps, too inert.
>
> When combined with the querySelector problem, this seems especially bad,
> since jQuery-style invocations would expect everything matching, say,
> $('img') to behave the same way (I guess we already have this problem with
> SVG <a> tags, but it seems especially weird in a document that one might
> think is all-HTML).
>

That's unfortunate.  I guess that means CSS styles will get applied to them
as well, which wouldn't be what authors would want.

Adam

Received on Wednesday, 18 July 2012 20:36:27 UTC