Skip to content

Commit 3a18a37

Browse files
johnjenkinsJohn Jenkinschristian-bromann
authored
fix(runtime): stop applying patches to non-shadow / non-render() components (#6349)
* fix(runtime): do not apply other patches to non-slot components * chore: use hasRenderFn * chore: revert test revert :D * chore: tidy --------- Co-authored-by: John Jenkins <[email protected]> Co-authored-by: Christian Bromann <[email protected]>
1 parent a93db56 commit 3a18a37

File tree

5 files changed

+18
-7
lines changed

5 files changed

+18
-7
lines changed

src/runtime/bootstrap-custom-element.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,8 @@ export const proxyCustomElement = (Cstr: any, compactMeta: d.ComponentRuntimeMet
4343
cmpMeta.$flags$ |= CMP_FLAGS.needsShadowDomShim;
4444
}
4545

46-
// TODO(STENCIL-914): this check and `else` block can go away and be replaced by just the `scoped` check
47-
if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation)) {
48-
if (BUILD.experimentalSlotFixes && cmpMeta.$flags$ & CMP_FLAGS.hasSlotRelocation) {
46+
if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && cmpMeta.$flags$ & CMP_FLAGS.hasRenderFn) {
47+
if (BUILD.experimentalSlotFixes) {
4948
patchPseudoShadowDom(Cstr.prototype);
5049
} else {
5150
if (BUILD.slotChildNodesFix) {

src/runtime/bootstrap-lazy.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,8 @@ export const bootstrapLazy = (lazyBundles: d.LazyBundlesRuntimeData, options: d.
195195
}
196196
};
197197

198-
if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation)) {
199-
// TODO(STENCIL-914): this check and `else` block can go away and be replaced by just the `scoped` check
200-
if (BUILD.experimentalSlotFixes && cmpMeta.$flags$ & CMP_FLAGS.hasSlotRelocation) {
198+
if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && cmpMeta.$flags$ & CMP_FLAGS.hasRenderFn) {
199+
if (BUILD.experimentalSlotFixes) {
201200
patchPseudoShadowDom(HostElement.prototype);
202201
} else {
203202
if (BUILD.slotChildNodesFix) {

src/utils/constants.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,11 @@ export const enum CMP_FLAGS {
119119
* to have its styles scoped during SSR as opposed to using DSD.
120120
*/
121121
shadowNeedsScopedCss = 1 << 7,
122+
123+
/**
124+
* Determines if a component has a render function.
125+
*/
126+
hasRenderFn = 1 << 8,
122127
}
123128

124129
/**

src/utils/format-component-runtime-meta.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ export const formatComponentRuntimeMeta = (
3535
if (compilerMeta.encapsulation !== 'shadow' && compilerMeta.htmlTagNames.includes('slot')) {
3636
flags |= CMP_FLAGS.hasSlotRelocation;
3737
}
38+
if (compilerMeta.hasRenderFn) {
39+
flags |= CMP_FLAGS.hasRenderFn;
40+
}
3841
if (compilerMeta.hasMode) {
3942
flags |= CMP_FLAGS.hasMode;
4043
}

test/end-to-end/src/dom-api/dom-api.e2e.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,10 +240,15 @@ describe('dom api e2e tests', () => {
240240

241241
await page.waitForChanges();
242242

243-
expect(elm).toEqualText(`updated text content`);
243+
expect(elm).toEqualText(`
244+
dom apiupdated text content
245+
`);
244246

245247
expect(elm).toEqualHtml(`
246248
<dom-api custom-hydrate-flag="">
249+
<span class="blue green red" data-a="a" data-z="z">
250+
dom api
251+
</span>
247252
updated text content
248253
</dom-api>
249254
`);

0 commit comments

Comments
 (0)