Closed Bug 646824 Opened 13 years ago Closed 13 years ago

appendChild does not evaluate the last script

Categories

(Core :: DOM: Core & HTML, defect)

x86
Linux
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 645115

People

(Reporter: Manuel.Serrano, Unassigned)

Details

User-Agent:       Mozilla/5.0 (X11; Linux i686; rv:2.0) Gecko/20110321 Firefox/4.0
Build Identifier: Firefox 4.0

Consider the following JS code:

foo.js:
function click( n ) {
   var el = document.createElement( "div" );
   var s = "<script>alert( \"1\" )</script>; bar <script>alert( \"2\"</script>; ";
   el.innerHTML = s;
   n.appendChild( el );
}

and then the following HTML file:

foo.html
<HTML>
<script src="/users/serrano/trashcan/foo.js" type='text/javascript'></script>
<DIV id="foo" onclick="click(this)">
click me
</DIV>
</HTML>

When the button is clicked, only *one* alert is executed. The second one is ignored. Actually, appendChild evaluate all the scripts but the last one.

Reproducible: Always

Steps to Reproduce:
1. firefox file:///tmp/foo.html
2. click the "click" work
3.
Actual Results:  
one "1" is raised in a popup

Expected Results:  
"1" _then_ "2" should be popped.
Note, you have a mistake in the script.
alert( \"2\" misses )
Usually it is better to attach testcases using "Add an attachment"
Per HTML5 spec, neither script should be evaluated in this case.

The fact that the first one is evaluated is bug 645115.
Status: UNCONFIRMED → RESOLVED
Closed: 13 years ago
Resolution: --- → DUPLICATE
Sorry, my mistake in a cut-and-paste for the error report. The actual script is:
function click( n ) {
   var el = document.createElement( "div" );
   var s = "<script>alert( \"1\" )</script>; bar <script>alert( \"2\" )</script>; ";
   el.innerHTML = s;
   n.appendChild( el );
}
Status: RESOLVED → UNCONFIRMED
Resolution: DUPLICATE → ---
Yes, but this is still a duplicate.
Status: UNCONFIRMED → RESOLVED
Closed: 13 years ago13 years ago
Resolution: --- → DUPLICATE
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.