fix(mock-doc): ensure event bubbling follows shadow DOM boundaries#6301
Merged
christian-bromann merged 2 commits intostenciljs:mainfrom Jun 16, 2025
Merged
fix(mock-doc): ensure event bubbling follows shadow DOM boundaries#6301christian-bromann merged 2 commits intostenciljs:mainfrom
christian-bromann merged 2 commits intostenciljs:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is the current behavior?
MockDoc bubbles DOM events to
parentElementevery time during simulation, completely ignoring the special boundary rules of the Shadow DOM. For example, with the following DOM structure:parent-host (Shadow Host) └── #shadow-root (Shadow Root) └── child-hostWhen the event bubbles from the
child-host, itsparentElementis null, but its container is the shadow-root, andshadow-root.hostpoints to theparent-host.GitHub Issue Number: #5676
What is the new behavior?
According to the W3C specification, when the event is set to
composed: true, it can cross Shadow DOM boundaries.Therefore, for the DOM structure example above, the correct bubbling path should be:
child → shadow-root → shadow-host → parent.Documentation
Does this introduce a breaking change?
Testing
Test Coverage:
Added consistency test: New test
src/mock-doc/test/shadow-dom-event-bubbling.spec.ts.Test Results:
✅ All 3 tests in the modified test file pass
Manual Verification:
In this minimal reproducible example, after linking
@stencil/coreand re-runningnpm run test, the previously failing test casemy-parent: logs 3 separate steps to the consolehas now succeeded.Other information