Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading