[whatwg] createContextualFragment in detached contexts
arv at chromium.org
Thu Sep 29 15:37:04 PDT 2011
Currently there is no easy way to create a tbody (and others from
markup). To do this correctly people have to go through ugly hacks
like what jQuery does  where they wrap the HTML string with the
right context elements and then grab the nodes inside that.
I would like to propose a change to createContextualFragment .
If the context object is in a detached state, then relax the parsing
rules so that all elements are allowed at that level. The hand wavy
explanation is that for every tag at the top level create a new
element in the same way that ownerDocument.createElement would do it.
This would allow the following to work.
var df = document.createRange().createContextualFragment('<tbody><tr><td>Hi</tbody>
assertEquals(' text ', df.childNodes.textContent);
More information about the whatwg