Skip to content

Commit da59978

Browse files
committed
chore: simplify style dedupe config
1 parent 51b9797 commit da59978

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

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

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -193,22 +193,26 @@ interface ComponentWithGenerateMarkup extends LightningElementConstructor {
193193

194194
export class RenderContext {
195195
styleDedupeIsEnabled: boolean;
196-
stylesheetToId = new WeakMap<Stylesheet, string>();
197196
styleDedupePrefix: string;
197+
stylesheetToId = new WeakMap<Stylesheet, string>();
198198
nextId = 0;
199199

200-
constructor(styleDedupePrefix: string, styleDedupeIsEnabled: boolean) {
201-
this.styleDedupeIsEnabled = styleDedupeIsEnabled;
202-
this.styleDedupePrefix = styleDedupePrefix;
200+
constructor(styleDedupe: string | boolean) {
201+
if (styleDedupe || styleDedupe === '') {
202+
this.styleDedupePrefix = styleDedupe && '';
203+
this.styleDedupeIsEnabled = true;
204+
} else {
205+
this.styleDedupePrefix = '';
206+
this.styleDedupeIsEnabled = false;
207+
}
203208
}
204209
}
205210

206211
export async function serverSideRenderComponent(
207212
tagName: string,
208213
Component: ComponentWithGenerateMarkup,
209214
props: Properties = {},
210-
styleDedupePrefix = '',
211-
styleDedupeIsEnabled = false,
215+
styleDedupe: string | boolean = '',
212216
mode: CompilationMode = DEFAULT_SSR_MODE
213217
): Promise<string> {
214218
if (typeof tagName !== 'string') {
@@ -222,7 +226,7 @@ export async function serverSideRenderComponent(
222226
markup += segment;
223227
};
224228

225-
emit.cxt = new RenderContext(styleDedupePrefix, styleDedupeIsEnabled);
229+
emit.cxt = new RenderContext(styleDedupe);
226230

227231
if (!generateMarkup) {
228232
// If a non-component is accidentally provided, render an empty template

0 commit comments

Comments
 (0)