Skip to content

fix(core): ensure pseudo shadow DOM getters return null instead of un…#6792

Open
ArjanEend wants to merge 1 commit into
stenciljs:mainfrom
ArjanEend:fix/pseudo-dom-null-returns
Open

fix(core): ensure pseudo shadow DOM getters return null instead of un…#6792
ArjanEend wants to merge 1 commit into
stenciljs:mainfrom
ArjanEend:fix/pseudo-dom-null-returns

Conversation

@ArjanEend

Copy link
Copy Markdown

…defined

What is the current behavior?

When using non-shadow/scoped components with experimentalSlotFixes: true, Stencil patches several Node/Element properties via patchPseudoShadowDom. However, in edge/boundary conditions (such as requesting nextSibling on the last child, or firstChild on an empty host), the patched getters return undefined instead of null. This violates the WHATWG DOM specification (which states these accessors should return null when 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 in dom-extras.ts) to return null instead of undefined when a child or sibling node does not exist:

  • firstChild
  • lastChild
  • nextSibling
  • nextElementSibling
  • previousSibling
  • previousElementSibling
  • parentNode

This brings the pseudo Shadow DOM polyfill in line with standard WHATWG DOM expectations.

Documentation

N/A

Does this introduce a breaking change?

  • Yes
  • No

Testing

  • Added new unit tests in src/runtime/test/dom-extras.spec.tsx (returns null (not undefined) for out-of-bounds siblings/children and returns null (not undefined) for firstChild/lastChild on empty patched hosts) verifying that all modified getters return null under boundary conditions.
  • Verified that all unit tests in the suite pass successfully: npm run test.jest -- src/runtime/test/dom-extras.spec.tsx
  • Verified the codebase builds successfully: npm run build

Other information

Fixes #6647

@ArjanEend
ArjanEend requested a review from a team as a code owner July 24, 2026 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: Problem with external SaaS tool since update 4.26.0

1 participant