fix(core): ensure pseudo shadow DOM getters return null instead of un…#6792
Open
ArjanEend wants to merge 1 commit into
Open
fix(core): ensure pseudo shadow DOM getters return null instead of un…#6792ArjanEend wants to merge 1 commit into
ArjanEend wants to merge 1 commit into
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.
…defined
What is the current behavior?
When using non-shadow/scoped components with
experimentalSlotFixes: true, Stencil patches several Node/Element properties viapatchPseudoShadowDom. However, in edge/boundary conditions (such as requestingnextSiblingon the last child, orfirstChildon an empty host), the patched getters returnundefinedinstead ofnull. This violates the WHATWG DOM specification (which states these accessors should returnnullwhen no matching node is found) and breaks third-party library integrations (e.g. Usabilla/Get Feedback).GitHub Issue Number: N/A (reported on community forums/GitHub issues)
What is the new behavior?
Modified the custom DOM getters inside
patchPseudoShadowDom(specifically indom-extras.ts) to returnnullinstead ofundefinedwhen a child or sibling node does not exist:firstChildlastChildnextSiblingnextElementSiblingpreviousSiblingpreviousElementSiblingparentNodeThis brings the pseudo Shadow DOM polyfill in line with standard WHATWG DOM expectations.
Documentation
N/A
Does this introduce a breaking change?
Testing
src/runtime/test/dom-extras.spec.tsx(returns null (not undefined) for out-of-bounds siblings/childrenandreturns null (not undefined) for firstChild/lastChild on empty patched hosts) verifying that all modified getters returnnullunder boundary conditions.npm run test.jest -- src/runtime/test/dom-extras.spec.tsxnpm run buildOther information
Fixes #6647