diff --git a/core/pfe-core/controllers/light-dom-controller.ts b/core/pfe-core/controllers/light-dom-controller.ts index e53d11cd5c..321010a467 100644 --- a/core/pfe-core/controllers/light-dom-controller.ts +++ b/core/pfe-core/controllers/light-dom-controller.ts @@ -1,4 +1,4 @@ -import type { ReactiveController, ReactiveElement } from 'lit'; +import { isServer, type ReactiveController, type ReactiveElement } from 'lit'; import { Logger } from './logger.js'; @@ -52,9 +52,13 @@ export class LightDOMController implements ReactiveController { * Returns a boolean statement of whether or not this component contains any light DOM. */ hasLightDOM(): boolean { - return !!( - this.host.children.length > 0 - || (this.host.textContent ?? '').trim().length > 0 - ); + if (isServer) { + return false; + } else { + return !!( + this.host.children.length > 0 + || (this.host.textContent ?? '').trim().length > 0 + ); + } } } diff --git a/core/pfe-core/controllers/scroll-spy-controller.ts b/core/pfe-core/controllers/scroll-spy-controller.ts index 89af9d2481..90cb254b1d 100644 --- a/core/pfe-core/controllers/scroll-spy-controller.ts +++ b/core/pfe-core/controllers/scroll-spy-controller.ts @@ -44,7 +44,7 @@ export class ScrollSpyController implements ReactiveController { #rootMargin?: string; #threshold: number | number[]; - #getRootNode: () => Node; + #getRootNode: () => Node | null; #getHash: (el: Element) => string | null; get #linkChildren(): Element[] { @@ -92,7 +92,7 @@ export class ScrollSpyController implements ReactiveController { this.#rootMargin = options.rootMargin; this.#activeAttribute = options.activeAttribute ?? 'active'; this.#threshold = options.threshold ?? 0.85; - this.#getRootNode = () => options.rootNode ?? host.getRootNode(); + this.#getRootNode = () => options.rootNode ?? host.getRootNode?.() ?? null; this.#getHash = options?.getHash ?? ((el: Element) => el.getAttribute('href')); } diff --git a/core/pfe-core/controllers/slot-controller.ts b/core/pfe-core/controllers/slot-controller.ts index a18344b989..2a7671bc33 100644 --- a/core/pfe-core/controllers/slot-controller.ts +++ b/core/pfe-core/controllers/slot-controller.ts @@ -191,8 +191,12 @@ export class SlotController implements ReactiveController { #getChildrenForSlot( name: string | typeof SlotController.default, ): T[] { - const children = Array.from(this.host.children) as T[]; - return children.filter(isSlot(name)); + if (isServer) { + return []; + } else { + const children = Array.from(this.host.children) as T[]; + return children.filter(isSlot(name)); + } } #initSlot = (slotName: string | null) => {