Skip to content

Commit 1bddaa9

Browse files
committed
fix: update context usage for ssr
1 parent cd54b8b commit 1bddaa9

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

.changeset/clear-pugs-make.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@patternfly/pfe-core": patch
3+
"@patternfly/elements": patch
4+
---
5+
Enable context protocol in SSR scenarios.

core/pfe-core/functions/context.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ function makeContextRoot() {
77
const root = new ContextRoot();
88
if (!isServer) {
99
root.attach(document.body);
10+
} else {
11+
root.attach(
12+
// @ts-expect-error: enable context root in ssr
13+
globalThis.litServerRoot,
14+
);
1015
}
1116
return root;
1217
}

core/pfe-core/ssr-shims.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ globalThis.window ??= globalThis;
3434
globalThis.document ??= new MiniDocument();
3535
// @ts-expect-error: this runs in node
3636
globalThis.navigator ??= { userAgent: '' };
37+
// @ts-expect-error: opt in to event support in ssr
38+
globalThis.litSsrCallConnectedCallback = true;
3739
// @ts-expect-error: this runs in node
3840
globalThis.ErrorEvent ??= Event;
3941
// @ts-expect-error: this runs in node
@@ -55,4 +57,3 @@ globalThis.getComputedStyle ??= function() {
5557
}
5658

5759
;
58-

0 commit comments

Comments
 (0)