fix: patchChildSlotNodes
& scopedSlotTextContentFix
not being applied
#6055
+261
−222
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?
GitHub Issue Number: #6054
TLDR ...
customElement.childNodes
,customElement.children
monkey-patches are never actually switched-on in Stencil atm.scopedSlotTextContentFix
doesn't fully patch thetextContent
....
Contrary to documentation, the
experimentalSlotFixes
orslotChildNodesFix
flags have no affect on thechildNodes
orchildren
accessors. The patches are only applied if the deprecatedneedsShadowDomShim
flag is fulfilled.This must be a mistake / a hangover from supporting legacy browsers.
Additionally
scopedSlotTextContentFix
alone doesn't fully patch thehost.textContent
accessor. It adds a half-way patch - which I believe to be more confusing than useful.To get the full
textContent
patch users much add bothexperimentalScopedSlotChanges
ANDscopedSlotTextContentFix
(experimentalScopedSlotChanges
alone won't add ANY patch).What is the new behavior?
Adding
experimentalSlotFixes
orslotChildNodesFix
now patcheschildNodes
,children
andchildElementCount
- they only return the nodes / elements that have been slotted - not the items within the component internals. This more closely mimics shadowRoot enabled components.I have removed the
experimentalScopedSlotChanges
for thetextContent
patch.Users need only apply
scopedSlotTextContentFix
or the unifiedexperimentalSlotFixes
.Additionally, I have rolled-in the
experimentalScopedSlotChanges
flag within the unifiedexperimentalSlotFixes
flag - I believe this makes sense asexperimentalScopedSlotChanges
will eventually be 'on' by default.Documentation
Does this introduce a breaking change?
Testing
dom-extras
.text-content-patch
test now only tests for the slotted text and doesn't return internal text)Other information
Making these changes did open a slight a can of worms because the codebase has never actually dealt with
host.childNodes
being monkey patched; everything assumes it will return a full list of component internals...To fix this, using the precedent of
appendChild
(and similar methods) withindom-extras.ts
, I have added a__childNodes
accessor to return a component's 'internal' nodes.