Re: [webcomponents] Template element parser changes => Proposal for adding DocumentFragment.innerHTML

On Wed, 09 May 2012 19:01:42 +0200, Ian Hickson <ian@hixie.ch> wrote:

>
> Quick alternative proposal that might work for both <template> parsing  
> and
> DocumentFragment.innerHTML:
>
>    Have createDocumentFragment() take as an argument a context element.
>    Maybe also make it a mutable attribute of the object. Defaults to its
>    owner document's body element or root element or some such. Null means
>    no root element.
>
>      var df = document.createDocumentFragment(document.body);
>      df.contextElement = document.createElement('style');

Or just string with the tag name, so it works the same as <template  
context>?

>    Have innerHTML use that as the context element to the fragment parsing
>    algorithm.
>
>      df.innerHTML = 'p::before { content: '<hello> <world>'; }';
>
>    Have <template> take an argument that's the element tag name for it to
>    use to create its context element. Defaults to <body>.
>     <template context="tr"> <td> </template>
>      <template context="svg"> <g/> </template>
>
>    Parse <template> by creating a new Document object that's like the  
> ones
>    you get from createDocument() (i.e. "dead"), and then creating a
>    DocumentFragment owned by that Document, and then pushing that
>    DocumentFragment onto the stack instead of the <template> element, but
>    set up to act like the <template> element for the purposes of being
>    popped off. (Except when parsing without a browsing context, then you
>    just parse normally.)
>
> Not sure how solid this is, but it's an idea at least. Hopefully an
> original one, though I'm sure y'all have considered it before. :-)
>


-- 
Simon Pieters
Opera Software

Received on Wednesday, 9 May 2012 17:25:51 UTC