W3C home > Mailing lists > Public > whatwg@whatwg.org > February 2011

[whatwg] documentFragment and innerHTML

From: Rafael Holt <raf@ratherodd.com>
Date: Sat, 26 Feb 2011 14:52:18 +0000
Message-ID: <AANLkTikcqBZ_qdzfMXVweq=vtzGbu6FpjONtxATe8QMd@mail.gmail.com>
On Fri, Feb 25, 2011 at 4:18 PM, Boris Zbarsky <bzbarsky at mit.edu> wrote:
> If you want to parse this string:
>  <form><tr><td>Some text</td></tr></form>
> then the DOM it produces depends on whether it's being parsed in the
> of a <table> parent element or not.  Try setting the innerHTML of a
> and a <div> to the above string, and examine the resulting DOM trees.
> That's what I meant when I said that to properly parse a string you need
> know the context it's being parsed in.

Thank you Boris, a very nice example.

On 25 February 2011 21:56, Aryeh Gregor <Simetrical+w3c at gmail.com> wrote:

> Isn't this exactly what insertAdjacentHTML() does?
> http://www.whatwg.org/specs/web-apps/current-work/multipage/apis-in-html-documents.html#insertadjacenthtml()

Yes, I had just never heard of insertAdjacentHTML(), since it doesn't enjoy
Webkit or Gecko support. Once it does though, I agree it's a nice addition.

As for createContextualFragment(), it bring unnecessary complexity to this,
having to mess about with ranges.

Thanks for pointing out insertAdjacentHTML() - I'll keep an eye on its
implementation progress.

Received on Saturday, 26 February 2011 06:52:18 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:31 UTC