Skip to content

Commit 141781e

Browse files
author
Sara Dahan
committed
fix(label-group): wrap #labels getter with server check to avoid DOM access in SSR
1 parent 16212ee commit 141781e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

elements/pf-label-group/pf-label-group.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,15 @@ export class PfLabelGroup extends LitElement {
108108
})
109109
private _categorySlotted?: HTMLElement[];
110110

111-
get #labels(): NodeListOf<PfLabel> {
111+
get #labels(): NodeListOf<PfLabel> | PfLabel[] {
112+
const isServer = typeof window === 'undefined' || !('document' in globalThis);
113+
if (isServer) {
114+
return [] as PfLabel[];
115+
}
112116
return this.querySelectorAll<PfLabel>('pf-label:not([slot]):not([overflow-label])');
113117
}
114118

119+
115120
#tabindex = RovingTabindexController.of(this, {
116121
getItems: () => [
117122
...Array.prototype.slice.call(

0 commit comments

Comments
 (0)