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

On Wed, Jul 18, 2012 at 10:43 AM, Ian Hickson <ian@hixie.ch> wrote:

> On Wed, 18 Jul 2012, Adam Barth 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.
>
> To handle multiple namespaces (specifically SVG and MathML), we could say
> that "inert" namespaces are namespaces that start with or end with a
> particular prefix, e.g. that are in the inert: scheme or that end with
> #inert. Then to de-inert nodes, you just strip the relevant part of the
> namespace string when cloning.
>
> To make this work in HTML with nested namespaces might be interesting:
>
>    <template>
>      <div>
>        <svg>
>          <foreignObject>
>            <math>
>              <mi>
>                <var>
>
> I guess what we do in the HTML parser is have it use all the same
> codepaths as now, except the "create an element" operations check if
> there's a <template> on the stack, and if there is, then they add the
> inert marker to the namespace, but everything else in the parser acts as
> if the marker is not there?
>

Yeah, that could work.  We also need to consider nested templates:

<template>
  <div>
    <template>
      <span>

I suspect we'll want the <span> to be in the same "inert" namespace as the
<div>, not doubly inerted.

Adam

Received on Wednesday, 18 July 2012 17:48:37 UTC