3 ms·
transplanting a node into a different document while the document.write() merrily marches along. It feels like open heart surgery with a rusty knife. But I can
by the8472 10y ago
transplanting a node into a different document while the document.write() merrily marches along.
It feels like open heart surgery with a rusty knife. But I can't find anything in the specs saying that it is verboten.
- mmastrac 10y agoTechnically you should be adopting the node, but I guess browsers don't care: https://developer.mozilla.org/en-US/docs/Web/API/Document/adoptNode https://developer.mozilla.org/en-US/docs/Web/API/Document/ad...
- the8472 10y agoThat shouldn't affect the parser, because adoptNode "simply" (read: dark rituals involving goats) changes owner document and the prototype chain but not object identity, which means the node on the parser stack should still be valid. The trick here is that the the invoked behavior is spread over the HTML5 and DOM specs and maybe a little Ecmascript too. In isolation they appear sane, combined together they are loose enough that this hack does not run afoul of any rules.
- jaffathecake 10y agoAs far as I can tell, adopting happens automatically https://dom.spec.whatwg.org/#concept-node-pre-insert https://dom.spec.whatwg.org/#concept-node-pre-insert