@@ -130,7 +130,11 @@ export const initializeClientHydrate = (
130
130
// 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)
131
131
node [ 's-cr' ] = hostElm [ 's-cr' ] ;
132
132
}
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
+ ) {
134
138
// if this child is a non-shadow component being added to a shadowDOM,
135
139
// let's find and add its styles to the shadowRoot, so we don't get a visual flicker
136
140
const cmpMeta = getHostRef ( childRenderNode . $elm$ ) ;
@@ -215,6 +219,11 @@ export const initializeClientHydrate = (
215
219
216
220
const hostEle = hosts [ slottedItem . hostId as any ] ;
217
221
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
+
218
227
// This node is either slotted in a non-shadow host, OR *that* host is nested in a non-shadow host
219
228
if ( ! hostEle . shadowRoot || ! shadowRoot ) {
220
229
// Try to set an appropriate Content-position Reference (CR) node for this host element
@@ -235,16 +244,22 @@ export const initializeClientHydrate = (
235
244
// Create our 'Original Location' node
236
245
addSlotRelocateNode ( slottedItem . node , slottedItem . slot , false , slottedItem . node [ 's-oo' ] ) ;
237
246
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
+
238
258
if ( BUILD . experimentalSlotFixes ) {
239
259
// patch this node for accessors like `nextSibling` (et al)
240
260
patchSlottedNode ( slottedItem . node ) ;
241
261
}
242
262
}
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
- }
248
263
}
249
264
}
250
265
@@ -693,22 +708,28 @@ const addSlottedNodes = (
693
708
let slottedNode = slotNode . nextSibling as d . RenderNode ;
694
709
slottedNodes [ slotNodeId as any ] = slottedNodes [ slotNodeId as any ] || [ ] ;
695
710
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 + '.' ) ) ;
712
733
} ;
713
734
714
735
/**
0 commit comments