Skip to content

Commit

Permalink
chore: simplify style dedupe config
Browse files Browse the repository at this point in the history
  • Loading branch information
wjhsf committed Mar 6, 2025
1 parent 51b9797 commit da59978
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions packages/@lwc/ssr-runtime/src/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,22 +193,26 @@ interface ComponentWithGenerateMarkup extends LightningElementConstructor {

export class RenderContext {
styleDedupeIsEnabled: boolean;
stylesheetToId = new WeakMap<Stylesheet, string>();
styleDedupePrefix: string;
stylesheetToId = new WeakMap<Stylesheet, string>();
nextId = 0;

constructor(styleDedupePrefix: string, styleDedupeIsEnabled: boolean) {
this.styleDedupeIsEnabled = styleDedupeIsEnabled;
this.styleDedupePrefix = styleDedupePrefix;
constructor(styleDedupe: string | boolean) {
if (styleDedupe || styleDedupe === '') {
this.styleDedupePrefix = styleDedupe && '';
this.styleDedupeIsEnabled = true;
} else {
this.styleDedupePrefix = '';
this.styleDedupeIsEnabled = false;
}
}
}

export async function serverSideRenderComponent(
tagName: string,
Component: ComponentWithGenerateMarkup,
props: Properties = {},
styleDedupePrefix = '',
styleDedupeIsEnabled = false,
styleDedupe: string | boolean = '',
mode: CompilationMode = DEFAULT_SSR_MODE
): Promise<string> {
if (typeof tagName !== 'string') {
Expand All @@ -222,7 +226,7 @@ export async function serverSideRenderComponent(
markup += segment;
};

emit.cxt = new RenderContext(styleDedupePrefix, styleDedupeIsEnabled);
emit.cxt = new RenderContext(styleDedupe);

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

0 comments on commit da59978

Please sign in to comment.