File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -627,13 +627,16 @@ export class VueElement
627
627
* Only called when shadowRoot is false
628
628
*/
629
629
private _parseSlots ( remove : boolean = true ) {
630
+ if ( ! this . _slotNames ) this . _slotNames = new Set ( )
631
+ else this . _slotNames . clear ( )
632
+
630
633
const slots : VueElement [ '_slots' ] = ( this . _slots = { } )
631
634
let n = this . firstChild
632
635
while ( n ) {
633
636
const slotName =
634
637
( n . nodeType === 1 && ( n as Element ) . getAttribute ( 'slot' ) ) || 'default'
635
638
; ( slots [ slotName ] || ( slots [ slotName ] = [ ] ) ) . push ( n )
636
- ; ( this . _slotNames || ( this . _slotNames = new Set ( ) ) ) . add ( slotName )
639
+ this . _slotNames . add ( slotName )
637
640
const next = n . nextSibling
638
641
if ( remove ) this . removeChild ( n )
639
642
n = next
@@ -728,10 +731,10 @@ export class VueElement
728
731
729
732
// switch between fallback and provided content
730
733
if ( this . _slotFallbacks ) {
731
- const oldSlotNames = Object . keys ( this . _slots ! )
734
+ const oldSlotNames = Array . from ( this . _slotNames ! )
732
735
// re-parse slots
733
736
this . _parseSlots ( false )
734
- const newSlotNames = Object . keys ( this . _slots ! )
737
+ const newSlotNames = Array . from ( this . _slotNames ! )
735
738
const allSlotNames = new Set ( [ ...oldSlotNames , ...newSlotNames ] )
736
739
allSlotNames . forEach ( name => {
737
740
const fallbackNodes = this . _slotFallbacks ! [ name ]
You can’t perform that action at this time.
0 commit comments