1- import { isServer , type ReactiveController , type ReactiveElement } from 'lit' ;
1+ import type { ReactiveController , ReactiveElement } from 'lit' ;
22
33interface AnonymousSlot {
44 hasContent : boolean ;
@@ -110,8 +110,6 @@ export class SlotController implements SlotControllerPublicAPI {
110110
111111 #slotNames: ( string | null ) [ ] = [ ] ;
112112
113- #ssrHintHasSlotted: ( string | null ) [ ] = [ ] ;
114-
115113 #deprecations: Record < string , string > = { } ;
116114
117115 #mo = new MutationObserver ( this . #initSlotMap. bind ( this ) ) ;
@@ -137,11 +135,6 @@ export class SlotController implements SlotControllerPublicAPI {
137135
138136 async hostConnected ( ) : Promise < void > {
139137 this . #mo. observe ( this . host , { childList : true } ) ;
140- this . #ssrHintHasSlotted =
141- this . host
142- // @ts -expect-error: this is a ponyfill for ::has-slotted, is not intended as a public API
143- . ssrHintHasSlotted
144- ?? [ ] ;
145138 // Map the defined slots into an object that is easier to query
146139 this . #nodes. clear ( ) ;
147140 this . #initSlotMap( ) ;
@@ -169,30 +162,23 @@ export class SlotController implements SlotControllerPublicAPI {
169162 const elements = this . #getChildrenForSlot( slotId ) ;
170163 const slot = this . #getSlotElement( slotId ) ;
171164 const hasContent =
172- isServer ? this . #ssrHintHasSlotted. includes ( slotName )
173- : ! ! elements . length || ! ! slot ?. assignedNodes ?.( ) ?. filter ( x => x . textContent ?. trim ( ) ) . length ;
165+ ! ! elements . length || ! ! slot ?. assignedNodes ?.( ) ?. filter ( x => x . textContent ?. trim ( ) ) . length ;
174166 this . #nodes. set ( slotId , { elements, name, hasContent, slot } ) ;
175167 }
176168 this . host . requestUpdate ( ) ;
177169 this . #slotMapInitialized = true ;
178170 }
179171
180172 #getSlotElement( slotId : string | symbol ) {
181- if ( isServer ) {
182- return null ;
183- } else {
184- const selector =
173+ const selector =
185174 slotId === SlotController . default ? 'slot:not([name])' : `slot[name="${ slotId as string } "]` ;
186- return this . host . shadowRoot ?. querySelector ?.< HTMLSlotElement > ( selector ) ?? null ;
187- }
175+ return this . host . shadowRoot ?. querySelector ?.< HTMLSlotElement > ( selector ) ?? null ;
188176 }
189177
190178 #getChildrenForSlot< T extends Element = Element > (
191179 name : string | typeof SlotController . default ,
192180 ) : T [ ] {
193- if ( isServer ) {
194- return [ ] ;
195- } else if ( this . #nodes. has ( name ) ) {
181+ if ( this . #nodes. has ( name ) ) {
196182 return ( this . #nodes. get ( name ) ! . slot ?. assignedElements ?.( ) ?? [ ] ) as T [ ] ;
197183 } else {
198184 const children = Array . from ( this . host . children ) as T [ ] ;
0 commit comments