Contents
What are the three phases of event propagation?
These three phases in order are 1) the event capturing phase, 2) the target phase, and 3) the event bubbling phase. The target element refers to the exact spot that is triggering the event.
What is containment hierarchy lightning?
Propagating to Container components By default, every parent in the containment hierarchy can’t handle an event during the capture and bubble phases. Instead, the event propagates to every owner in the containment hierarchy. To put it simply: A Lightning component hierarchy does not behave like a DOM tree.
Can a capture event be handled in Lightning?
Lightning component events also support both capture and bubble phases, but there are some framework specificities in terms of syntax and behavior. By default, component events are handled in the bubble phase, and that’s what most developers use.
How does capture and bubble work in Lightning?
The capture phase executes before the bubble phase. The source component, which is the innermost component fires the event. Now when the event is generated, it travels up its hierarchy until it reaches the outermost component which is also the owner of the component. This is called bubbling.
How are application events used in Lightning component?
Application events are used when you need two independent component to communicate with each other i.e. they don’t need to be in the component hierarchy or nested within each other. Application events are handled by all components that are listening to the event. These events are essentially a traditional publish-subscribe model.
How does event propagation work in Lightning aura?
Application Event Propagation The framework supports capture, bubble, and default phases for the propagation of application events. The capture and bubble phases are similar to DOM handling patterns and provide an opportunity for interested components to interact with an event and potentially control the behavior for subsequent handlers.