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

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

From: Scott González <scott.gonzalez@gmail.com>
Date: Fri, 11 May 2012 08:39:37 -0400
Message-ID: <CAO8i3iduQQzV8jQ7G==s9k7a498H75n9bpnMX1VJR0ObPeNA4g@mail.gmail.com>
To: Henri Sivonen <hsivonen@iki.fi>
Cc: "Tab Atkins Jr." <jackalmage@gmail.com>, Rafael Weinstein <rafaelw@google.com>, Webapps WG <public-webapps@w3.org>, Yehuda Katz <wycats@gmail.com>
On Fri, May 11, 2012 at 7:13 AM, Henri Sivonen <hsivonen@iki.fi> wrote:

> However, I'm not strongly opposed to adding innerHTML to
> DocumentFragment if we also add a method on Document that parses a
> string using the HTML parser regardless of the HTMLness flag of the
> document and returns a DocumentFragment (or has an optional extra
> argument for forcing XML parsing explicitly).
>

Just a side note, but at least parsing XML seems to be fairly sane today. I
haven't really done any testing around this, but it seems like this would
get you parsing of arbitrary XML fragments, including leading and trailing
text nodes:

(new DOMParser).parseFromString( "<x>" + string + "</x>", "text/xml"
).documentElement.childNodes

Obviously this is overly verbose compared to document.parse( string, flag ).
Received on Friday, 11 May 2012 12:40:12 GMT

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