[whatwg] documentFragment and innerHTML

Rafael Holt raf at ratherodd.com
Sat Feb 26 06:52:18 PST 2011


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
context
> of a <table> parent element or not.  Try setting the innerHTML of a
<table>
> 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
to
> 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.

Rafael



More information about the whatwg mailing list