I recently encountered a related bug when tuning netsurf: alert() was called twice. html code:
function causealert()
{
var txt = document.getElementById("p1").textContent;
alert(txt);
}
First line of paragraph.
< /p>
<script><br>var Button1 = document.getElementById("button1");<br>/*var Button1Click = function() { alert(1); }; <br>Button1.addEventListener("click ", Button1Click, false);*/<br>Button1.onclick = causealert;</p> <p></script>
/* Bubbling phase */
evt->phase = DOM_BUBBLING_PHASE;
for (targetnr = 0; targetnr < ntargets; targetnr)
The event flow is like this: p1(root)-->p2-->... --> pm --> T (capturing phase), T (target phase), T--> ; pm --> ... --> p1 (bubbling phase).
The specification stipulates that only one of capturing and bubbling can be selected. In the code, capturing is selected in js_dom_event_add_listener(). This explains why alert is executed twice.
Modification: According to the DOM 3 specification, just change the above 0 to 1.