[whatwg] Inserting a DocumentFragment of multiple text nodes into a script element

Bjoern Hoehrmann derhoermi at gmx.net
Fri Oct 28 14:46:22 PDT 2011


* David Flanagan wrote:
>What is the correct behavior for the following code?
>
><script>
>window.onload = test;
>
>function test() {
>     var s = document.createElement("script");
>     document.head.appendChild(s);
>
>     var f = document.createDocumentFragment();
>     
>f.appendChild(document.createTextNode("alert(document.scripts[1].text);"));
>     f.appendChild(document.createTextNode("alert(2);"));
>     f.appendChild(document.createTextNode("alert(3);"));
>
>     s.appendChild(f);
>
>     alert(s.text);
>}
></script>
>
>In Firefox, the code in all three text nodes runs, so there are 4 alerts 
>in total, and the first and the fourth display the same text: the 
>concatenation of the three text nodes.

IE9 Standards mode is the same.
-- 
Björn Höhrmann · mailto:bjoern at hoehrmann.de · http://bjoern.hoehrmann.de
Am Badedeich 7 · Telefon: +49(0)160/4415681 · http://www.bjoernsworld.de
25899 Dagebüll · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/ 


More information about the whatwg mailing list