@@ -130,7 +130,11 @@ export const initializeClientHydrate = (
130130 // If we don't, `vdom-render.ts` will try to add nodes to it (and because it may be a comment node, it will error)
131131 node [ 's-cr' ] = hostElm [ 's-cr' ] ;
132132 }
133- } else if ( childRenderNode . $tag$ ?. toString ( ) . includes ( '-' ) && ! childRenderNode . $elm$ . shadowRoot ) {
133+ } else if (
134+ childRenderNode . $tag$ ?. toString ( ) . includes ( '-' ) &&
135+ childRenderNode . $tag$ !== 'slot-fb' &&
136+ ! childRenderNode . $elm$ . shadowRoot
137+ ) {
134138 // if this child is a non-shadow component being added to a shadowDOM,
135139 // let's find and add its styles to the shadowRoot, so we don't get a visual flicker
136140 const cmpMeta = getHostRef ( childRenderNode . $elm$ ) ;
@@ -215,6 +219,11 @@ export const initializeClientHydrate = (
215219
216220 const hostEle = hosts [ slottedItem . hostId as any ] ;
217221
222+ if ( hostEle . shadowRoot && slottedItem . node . parentElement !== hostEle ) {
223+ // shadowDOM - move the item to the element root for native slotting
224+ hostEle . appendChild ( slottedItem . node ) ;
225+ }
226+
218227 // This node is either slotted in a non-shadow host, OR *that* host is nested in a non-shadow host
219228 if ( ! hostEle . shadowRoot || ! shadowRoot ) {
220229 // Try to set an appropriate Content-position Reference (CR) node for this host element
@@ -235,16 +244,22 @@ export const initializeClientHydrate = (
235244 // Create our 'Original Location' node
236245 addSlotRelocateNode ( slottedItem . node , slottedItem . slot , false , slottedItem . node [ 's-oo' ] ) ;
237246
247+ if (
248+ slottedItem . node . parentElement ?. shadowRoot &&
249+ slottedItem . node [ 'getAttribute' ] &&
250+ slottedItem . node . getAttribute ( 'slot' )
251+ ) {
252+ // Remove the `slot` attribute from the slotted node:
253+ // if it's projected from a scoped component into a shadowRoot it's slot attribute will cause it to be hidden.
254+ // scoped components use the `s-sn` attribute to identify slotted nodes
255+ slottedItem . node . removeAttribute ( 'slot' ) ;
256+ }
257+
238258 if ( BUILD . experimentalSlotFixes ) {
239259 // patch this node for accessors like `nextSibling` (et al)
240260 patchSlottedNode ( slottedItem . node ) ;
241261 }
242262 }
243-
244- if ( hostEle . shadowRoot && slottedItem . node . parentElement !== hostEle ) {
245- // shadowDOM - move the item to the element root for native slotting
246- hostEle . appendChild ( slottedItem . node ) ;
247- }
248263 }
249264 }
250265
@@ -693,22 +708,28 @@ const addSlottedNodes = (
693708 let slottedNode = slotNode . nextSibling as d . RenderNode ;
694709 slottedNodes [ slotNodeId as any ] = slottedNodes [ slotNodeId as any ] || [ ] ;
695710
696- // Looking for nodes that match this slot's name,
697- // OR are text / comment nodes and the slot is a default slot (no name) - text / comments cannot be direct descendants of *named* slots.
698- // Also ignore slot fallback nodes - they're not part of the lightDOM
699- while (
700- slottedNode &&
701- ( ( ( slottedNode [ 'getAttribute' ] && slottedNode . getAttribute ( 'slot' ) ) || slottedNode [ 's-sn' ] ) === slotName ||
702- ( slotName === '' &&
703- ! slottedNode [ 's-sn' ] &&
704- ( slottedNode . nodeType === NODE_TYPE . CommentNode ||
705- slottedNode . nodeType === NODE_TYPE . TextNode ||
706- slottedNode . tagName === 'SLOT' ) ) )
707- ) {
708- slottedNode [ 's-sn' ] = slotName ;
709- slottedNodes [ slotNodeId as any ] . push ( { slot : slotNode , node : slottedNode , hostId } ) ;
710- slottedNode = slottedNode . nextSibling as d . RenderNode ;
711- }
711+ // stop if we find another slot node (as subsequent nodes will belong to that slot)
712+ if ( ! slottedNode || slottedNode . nodeValue ?. startsWith ( SLOT_NODE_ID + '.' ) ) return ;
713+
714+ // Loop through the next siblings of the slot node, looking for nodes that match this slot's name
715+ do {
716+ if (
717+ slottedNode &&
718+ ( ( ( slottedNode [ 'getAttribute' ] && slottedNode . getAttribute ( 'slot' ) ) || slottedNode [ 's-sn' ] ) === slotName ||
719+ ( slotName === '' &&
720+ ! slottedNode [ 's-sn' ] &&
721+ ( ! slottedNode [ 'getAttribute' ] || ! slottedNode . getAttribute ( 'slot' ) ) &&
722+ ( slottedNode . nodeType === NODE_TYPE . CommentNode || slottedNode . nodeType === NODE_TYPE . TextNode ) ) )
723+ ) {
724+ // Looking for nodes that match this slot's name,
725+ // OR are text / comment nodes and the slot is a default slot (no name) - text / comments cannot be direct descendants of *named* slots.
726+ // Also ignore slot fallback nodes - they're not part of the lightDOM
727+ slottedNode [ 's-sn' ] = slotName ;
728+ slottedNodes [ slotNodeId as any ] . push ( { slot : slotNode , node : slottedNode , hostId } ) ;
729+ }
730+ slottedNode = slottedNode ?. nextSibling as d . RenderNode ;
731+ // continue *unless* we find another slot node (as subsequent nodes will belong to that slot)
732+ } while ( slottedNode && ! slottedNode . nodeValue ?. startsWith ( SLOT_NODE_ID + '.' ) ) ;
712733} ;
713734
714735/**
0 commit comments