SF-PD2 User Interface Practice Question
A developer is building a Lightning Web Component that needs to communicate with a parent component in a deep containment hierarchy. The event must traverse shadow boundaries without stopping at component boundaries. Which property configuration should the developer apply when instantiating the CustomEvent?
⚠ Common exam trap
Many developers assume that setting bubbles: true alone is sufficient for an event to reach a parent component across a shadow boundary, forgetting that composed must also be true.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
{ bubbles: true, composed: true }
Custom events in Lightning Web Components require the bubbles and composed properties to be set to true when they need to cross shadow DOM boundaries and propagate up through the entire DOM tree, including parent and grandparent components. Setting composed to false restricts the event strictly within the local shadow tree of the component that dispatched it.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
{ bubbles: true, composed: false }
Why it's wrong here
Setting composed to false stops the event at the shadow boundary, so it never reaches ancestors in a deep hierarchy. It is tempting because bubbling alone is the correct choice when the requirement is propagating an event upward through the same shadow root only.
- ✗
{ bubbles: false, composed: true }
Why it's wrong here
Without bubbles, the event never propagates upward past the component that dispatched it, so no ancestor can receive it regardless of shadow boundaries. Composed:true only controls shadow DOM retargeting. Bubbling events are the norm for child-to-parent communication; composed matters when crossing shadow roots while still bubbling.
- ✓
{ bubbles: true, composed: true }
Why this is correct
Setting `composed: true` allows the event to cross shadow DOM boundaries, while `bubbles: true` propagates it up through the containment hierarchy. Together they satisfy the stem's requirement that the event traverse shadow boundaries without stopping, reaching the parent component regardless of nesting depth.
- ✗
{ cancelable: true, composed: false }
Why it's wrong here
Cancelable controls whether preventDefault can stop the event; composed false still halts propagation at the shadow boundary. It is tempting because cancelable is the correct choice when the requirement is allowing an ancestor to intercept and cancel the event's default behaviour.
About these practice questions
One of 226 original SF-PD2 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
JA
Written and reviewed by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
Last reviewed September 2026 · checked against the official Salesforce exam blueprint
This SF-PD2 practice question is part of Courseiva's free Salesforce certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the SF-PD2 exam.