[whatwg] documentFragment and innerHTML

Boris Zbarsky bzbarsky at MIT.EDU
Fri Feb 25 13:18:03 PST 2011

On 2/25/11 3:56 PM, raf at ratherodd.com wrote:
> I realise this is a niche scenario that is not often encountered, but I'd
> be interested in the rationale behind not implementing it, or whether
> others think it would be a good idea to add this feature. Boris Zbarsky
> indicated something about contexts to parse in that I didn't understand,
> so hopefully someone can enlighten me.

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.


More information about the whatwg mailing list