There are two onchange triggers: one on the INPUT and one from the FORM containing the INPUT.
document.getElementByTagName('form')[0].addEventListener('change',funcForm);
document.getElementByTagName('input')[0].addEventListener('change',funcInput);
-
does
funcFormorfuncInputfire first? -
is this behavior defined and consistent?
-
if
e.stopPropagation()is issued on the first firing trigger, does the second fire?
The input’s handlers should be triggered first and then the event should bubble up the DOM hierarchy if it bubbles. From the DOM Events specification:
The second paragraph applies to
stopPropagationand says that if the listener on theinputcallse.stopPropagation(), then the event should not get up to the<form>. However, any remaining listeners on the<input>will see the change event,stopPropagationjust keeps the event from bubbling up the tree any further than the level at whichstopPropagationis called.Furthermore, the change event does bubble: