File tree Expand file tree Collapse file tree 3 files changed +17
-9
lines changed
core/pfe-core/controllers Expand file tree Collapse file tree 3 files changed +17
-9
lines changed Original file line number Diff line number Diff line change 1- import type { ReactiveController , ReactiveElement } from 'lit' ;
1+ import { isServer , type ReactiveController , type ReactiveElement } from 'lit' ;
22
33import { Logger } from './logger.js' ;
44
@@ -52,9 +52,13 @@ export class LightDOMController implements ReactiveController {
5252 * Returns a boolean statement of whether or not this component contains any light DOM.
5353 */
5454 hasLightDOM ( ) : boolean {
55- return ! ! (
56- this . host . children . length > 0
57- || ( this . host . textContent ?? '' ) . trim ( ) . length > 0
58- ) ;
55+ if ( isServer ) {
56+ return false ;
57+ } else {
58+ return ! ! (
59+ this . host . children . length > 0
60+ || ( this . host . textContent ?? '' ) . trim ( ) . length > 0
61+ ) ;
62+ }
5963 }
6064}
Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ export class ScrollSpyController implements ReactiveController {
4444 #rootMargin?: string ;
4545 #threshold: number | number [ ] ;
4646
47- #getRootNode: ( ) => Node ;
47+ #getRootNode: ( ) => Node | null ;
4848 #getHash: ( el : Element ) => string | null ;
4949
5050 get #linkChildren( ) : Element [ ] {
@@ -92,7 +92,7 @@ export class ScrollSpyController implements ReactiveController {
9292 this . #rootMargin = options . rootMargin ;
9393 this . #activeAttribute = options . activeAttribute ?? 'active' ;
9494 this . #threshold = options . threshold ?? 0.85 ;
95- this . #getRootNode = ( ) => options . rootNode ?? host . getRootNode ( ) ;
95+ this . #getRootNode = ( ) => options . rootNode ?? host . getRootNode ?. ( ) ?? null ;
9696 this . #getHash = options ?. getHash ?? ( ( el : Element ) => el . getAttribute ( 'href' ) ) ;
9797 }
9898
Original file line number Diff line number Diff line change @@ -191,8 +191,12 @@ export class SlotController implements ReactiveController {
191191 #getChildrenForSlot< T extends Element = Element > (
192192 name : string | typeof SlotController . default ,
193193 ) : T [ ] {
194- const children = Array . from ( this . host . children ) as T [ ] ;
195- return children . filter ( isSlot ( name ) ) ;
194+ if ( isServer ) {
195+ return [ ] ;
196+ } else {
197+ const children = Array . from ( this . host . children ) as T [ ] ;
198+ return children . filter ( isSlot ( name ) ) ;
199+ }
196200 }
197201
198202 #initSlot = ( slotName : string | null ) => {
You can’t perform that action at this time.
0 commit comments