Skip to content

Commit a15bc5d

Browse files
johnjenkinsJohn Jenkins
and
John Jenkins
authored
fix: patchChildSlotNodes & scopedSlotTextContentFix not being applied (#6055)
* fix: `patchChildSlotNodes` not being applied properly * chore: well that escalated quickly * chore: don't patch global prototypes * chore: fix node-22 / windows tests --------- Co-authored-by: John Jenkins <john.jenkins@nanoporetech.com>
1 parent 7ecb599 commit a15bc5d

File tree

11 files changed

+255
-222
lines changed

11 files changed

+255
-222
lines changed

src/compiler/config/validate-config.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ export const validateConfig = (
150150
validatedConfig.extras.scriptDataOpts = !!validatedConfig.extras.scriptDataOpts;
151151
validatedConfig.extras.initializeNextTick = !!validatedConfig.extras.initializeNextTick;
152152
validatedConfig.extras.tagNameTransform = !!validatedConfig.extras.tagNameTransform;
153+
// TODO(STENCIL-1086): remove this option when it's the default behavior
154+
validatedConfig.extras.experimentalScopedSlotChanges = !!validatedConfig.extras.experimentalScopedSlotChanges;
153155

154156
// TODO(STENCIL-914): remove when `experimentalSlotFixes` is the default behavior
155157
// If the user set `experimentalSlotFixes` and any individual slot fix flags to `false`, we need to log a warning
@@ -160,6 +162,7 @@ export const validateConfig = (
160162
'slotChildNodesFix',
161163
'cloneNodeFix',
162164
'scopedSlotTextContentFix',
165+
'experimentalScopedSlotChanges',
163166
];
164167
const conflictingFlags = possibleFlags.filter((flag) => validatedConfig.extras[flag] === false);
165168
if (conflictingFlags.length > 0) {
@@ -185,9 +188,6 @@ export const validateConfig = (
185188
validatedConfig.extras.scopedSlotTextContentFix = !!validatedConfig.extras.scopedSlotTextContentFix;
186189
}
187190

188-
// TODO(STENCIL-1086): remove this option when it's the default behavior
189-
validatedConfig.extras.experimentalScopedSlotChanges = !!validatedConfig.extras.experimentalScopedSlotChanges;
190-
191191
setBooleanConfig(
192192
validatedConfig,
193193
'sourceMap',

src/declarations/stencil-private.ts

+7
Original file line numberDiff line numberDiff line change
@@ -1455,6 +1455,13 @@ export interface RenderNode extends HostElement {
14551455
* empty "" for shadow, "c" from scoped
14561456
*/
14571457
['s-en']?: '' | /*shadow*/ 'c' /*scoped*/;
1458+
1459+
/**
1460+
* On a `scoped: true` component
1461+
* with `experimentalSlotFixes` flag enabled,
1462+
* returns the internal `childNodes` of the scoped element
1463+
*/
1464+
readonly __childNodes?: NodeListOf<ChildNode>;
14581465
}
14591466

14601467
export type LazyBundlesRuntimeData = LazyBundleRuntimeData[];

src/runtime/bootstrap-custom-element.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ export const proxyCustomElement = (Cstr: any, compactMeta: d.ComponentRuntimeMet
4848
if (BUILD.scoped && cmpMeta.$flags$ & CMP_FLAGS.scopedCssEncapsulation) {
4949
// This check is intentionally not combined with the surrounding `experimentalSlotFixes` check
5050
// since, moving forward, we only want to patch the pseudo shadow DOM when the component is scoped
51-
patchPseudoShadowDom(Cstr.prototype, cmpMeta);
51+
patchPseudoShadowDom(Cstr.prototype);
5252
}
5353
} else {
5454
if (BUILD.slotChildNodesFix) {
55-
patchChildSlotNodes(Cstr.prototype, cmpMeta);
55+
patchChildSlotNodes(Cstr.prototype);
5656
}
5757
if (BUILD.cloneNodeFix) {
5858
patchCloneNode(Cstr.prototype);

src/runtime/bootstrap-lazy.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,11 @@ export const bootstrapLazy = (lazyBundles: d.LazyBundlesRuntimeData, options: d.
171171
// This check is intentionally not combined with the surrounding `experimentalSlotFixes` check
172172
// since, moving forward, we only want to patch the pseudo shadow DOM when the component is scoped
173173
if (BUILD.scoped && cmpMeta.$flags$ & CMP_FLAGS.scopedCssEncapsulation) {
174-
patchPseudoShadowDom(HostElement.prototype, cmpMeta);
174+
patchPseudoShadowDom(HostElement.prototype);
175175
}
176176
} else {
177177
if (BUILD.slotChildNodesFix) {
178-
patchChildSlotNodes(HostElement.prototype, cmpMeta);
178+
patchChildSlotNodes(HostElement.prototype);
179179
}
180180
if (BUILD.cloneNodeFix) {
181181
patchCloneNode(HostElement.prototype);

0 commit comments

Comments
 (0)