Skip to content

Commit

Permalink
fix: patchChildSlotNodes & scopedSlotTextContentFix not being app…
Browse files Browse the repository at this point in the history
…lied (#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 <[email protected]>
  • Loading branch information
johnjenkins and John Jenkins authored Nov 26, 2024
1 parent 7ecb599 commit a15bc5d
Show file tree
Hide file tree
Showing 11 changed files with 255 additions and 222 deletions.
6 changes: 3 additions & 3 deletions src/compiler/config/validate-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ export const validateConfig = (
validatedConfig.extras.scriptDataOpts = !!validatedConfig.extras.scriptDataOpts;
validatedConfig.extras.initializeNextTick = !!validatedConfig.extras.initializeNextTick;
validatedConfig.extras.tagNameTransform = !!validatedConfig.extras.tagNameTransform;
// TODO(STENCIL-1086): remove this option when it's the default behavior
validatedConfig.extras.experimentalScopedSlotChanges = !!validatedConfig.extras.experimentalScopedSlotChanges;

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

// TODO(STENCIL-1086): remove this option when it's the default behavior
validatedConfig.extras.experimentalScopedSlotChanges = !!validatedConfig.extras.experimentalScopedSlotChanges;

setBooleanConfig(
validatedConfig,
'sourceMap',
Expand Down
7 changes: 7 additions & 0 deletions src/declarations/stencil-private.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1455,6 +1455,13 @@ export interface RenderNode extends HostElement {
* empty "" for shadow, "c" from scoped
*/
['s-en']?: '' | /*shadow*/ 'c' /*scoped*/;

/**
* On a `scoped: true` component
* with `experimentalSlotFixes` flag enabled,
* returns the internal `childNodes` of the scoped element
*/
readonly __childNodes?: NodeListOf<ChildNode>;
}

export type LazyBundlesRuntimeData = LazyBundleRuntimeData[];
Expand Down
4 changes: 2 additions & 2 deletions src/runtime/bootstrap-custom-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ export const proxyCustomElement = (Cstr: any, compactMeta: d.ComponentRuntimeMet
if (BUILD.scoped && cmpMeta.$flags$ & CMP_FLAGS.scopedCssEncapsulation) {
// This check is intentionally not combined with the surrounding `experimentalSlotFixes` check
// since, moving forward, we only want to patch the pseudo shadow DOM when the component is scoped
patchPseudoShadowDom(Cstr.prototype, cmpMeta);
patchPseudoShadowDom(Cstr.prototype);
}
} else {
if (BUILD.slotChildNodesFix) {
patchChildSlotNodes(Cstr.prototype, cmpMeta);
patchChildSlotNodes(Cstr.prototype);
}
if (BUILD.cloneNodeFix) {
patchCloneNode(Cstr.prototype);
Expand Down
4 changes: 2 additions & 2 deletions src/runtime/bootstrap-lazy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,11 @@ export const bootstrapLazy = (lazyBundles: d.LazyBundlesRuntimeData, options: d.
// This check is intentionally not combined with the surrounding `experimentalSlotFixes` check
// since, moving forward, we only want to patch the pseudo shadow DOM when the component is scoped
if (BUILD.scoped && cmpMeta.$flags$ & CMP_FLAGS.scopedCssEncapsulation) {
patchPseudoShadowDom(HostElement.prototype, cmpMeta);
patchPseudoShadowDom(HostElement.prototype);
}
} else {
if (BUILD.slotChildNodesFix) {
patchChildSlotNodes(HostElement.prototype, cmpMeta);
patchChildSlotNodes(HostElement.prototype);
}
if (BUILD.cloneNodeFix) {
patchCloneNode(HostElement.prototype);
Expand Down
Loading

0 comments on commit a15bc5d

Please sign in to comment.