Skip to content

Commit 7e2a5de

Browse files
fix: render shadow slotted content for no template case
1 parent 012f15b commit 7e2a5de

File tree

4 files changed

+18
-25
lines changed

4 files changed

+18
-25
lines changed
Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
<x-outer>
2-
<x-inner>
3-
<template shadowrootmode="open">
4-
</template>
5-
slotted content
6-
<h2 slot="bob">
7-
more content
8-
</h2>
9-
</x-inner>
2+
<template shadowrootmode="open">
3+
<x-inner>
4+
<template shadowrootmode="open">
5+
</template>
6+
I am default slot
7+
<div slot="foo">
8+
I am the foo slot
9+
</div>
10+
</x-inner>
11+
</template>
1012
</x-outer>
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<x-inner>
3-
slotted content
4-
<h2 slot="bob">more content</h2>
3+
I am default slot
4+
<div slot="foo">I am the foo slot</div>
55
</x-inner>
66
</template>
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
import { LightningElement } from 'lwc';
22

3-
export default class extends LightningElement {
4-
static renderMode = 'light';
5-
}
3+
export default class extends LightningElement {}

packages/@lwc/ssr-runtime/src/render.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,9 @@ export function* fallbackTmpl(
109109
) {
110110
if (Cmp.renderMode !== 'light') {
111111
yield `<template shadowrootmode="open"></template>`;
112-
renderSlottedContent(_lightSlottedContent, _instance);
112+
if (_shadowSlottedContent) {
113+
yield _shadowSlottedContent(_instance);
114+
}
113115
}
114116
}
115117

@@ -123,17 +125,8 @@ export function fallbackTmplNoYield(
123125
) {
124126
if (Cmp.renderMode !== 'light') {
125127
emit(`<template shadowrootmode="open"></template>`);
126-
renderSlottedContent(_lightSlottedContent, emit);
127-
}
128-
}
129-
130-
function renderSlottedContent(_lightSlottedContent: any, contextfulParent: any) {
131-
if (_lightSlottedContent) {
132-
for (const slotName in _lightSlottedContent) {
133-
const generators = _lightSlottedContent[slotName];
134-
for (let i = 0; i < generators.length; i++) {
135-
generators[i](contextfulParent, null, slotName);
136-
}
128+
if (_shadowSlottedContent) {
129+
_shadowSlottedContent(emit, _instance);
137130
}
138131
}
139132
}

0 commit comments

Comments
 (0)