Javascript event propagation not working as expected -
window.document.addeventlistener('click', function(e) { event.preventdefault(); event.stoppropagation(); settimeout(function(){e.target.dispatchevent(e);}, 2000); }, true); <button onclick="console.log('test')">test</button>
why isn't event firing after 2 seconds? (it never fires)
according w3c dom level 3 events specficiation, event flow has 3 phases: capture, target , bubble. , if "…event.stoppropagation() has been called prior dispatch, phases must skipped".
so since stoppropagation has been called before event dispatched, no phase executed, including target phase.
javascript javascript-events event-propagation
No comments:
Post a Comment