According to quirksmode, modern browsers have a capturing phase and a bubbling phase. See here.
If I use stopPropagation in my event handler ( set to either phase by the Boolean argument ) how will it function?
Will it work both ways? That is if I set it to capture mode, will it also prevent the bubbling phase. And vice-versa as well.
Here is the W3 reference ( stopPropagation ).
I'm troubleshooting an event handler, and need to understand exactly how stopPropagation() functions.
Stopping propagation during the capture phase will prevent further handlers from running, including handlers registered with the bubbling phase.
The W3C documentation on event flow says (emphasis mine):
This specification defines three event phases: capture phase; target phase; and bubble phase. Event objects complete these phases in the specified order using the partial propagation paths as defined below. A phase must be skipped if it is not supported, or if the event object's propagation has been stopped. For example, if the
Event.bubblesattribute is set to false, the bubble phase will be skipped, and ifEvent.stopPropagation()has been called prior to the dispatch, all phases must be skipped.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With