@@ -255,6 +255,7 @@ export abstract class VueElementBase<
255255 protected abstract _mount ( def : Def ) : void
256256 protected abstract _update ( ) : void
257257 protected abstract _unmount ( ) : void
258+ protected abstract _updateSlotNodes ( slot : Map < Node , Node [ ] > ) : void
258259
259260 constructor (
260261 /**
@@ -663,58 +664,11 @@ export abstract class VueElementBase<
663664 replacementNodes . push ( child )
664665 }
665666 }
666-
667+ parent . removeChild ( o )
667668 slotReplacements . set ( o , replacementNodes )
668669 }
669670
670- // For Vapor: update fragment nodes before removing slots from DOM
671- if ( slotReplacements . size > 0 && this . _instance && this . _instance . vapor ) {
672- // @ts -expect-error TODO refactor
673- this . _replaceNodesInFragments ( this . _instance . block , slotReplacements )
674- }
675-
676- // Now safe to remove slots from DOM
677- slotReplacements . forEach ( ( _ , o ) => o . parentNode ! . removeChild ( o ) )
678- }
679-
680- /**
681- * Replace slot nodes with their content in fragment nodes arrays
682- * @internal
683- */
684- private _replaceNodesInFragments (
685- block : any ,
686- replacements : Map < Node , Node [ ] > ,
687- ) : void {
688- if ( ! block ) return
689-
690- if ( Array . isArray ( block ) ) {
691- for ( let i = 0 ; i < block . length ; i ++ ) {
692- this . _replaceNodesInFragments ( block [ i ] , replacements )
693- }
694- } else if ( block . nodes !== undefined ) {
695- // This is a fragment with nodes property
696- if ( Array . isArray ( block . nodes ) ) {
697- // Replace slot nodes with their content
698- const newNodes : any [ ] = [ ]
699- for ( const node of block . nodes ) {
700- if ( node instanceof Node && replacements . has ( node ) ) {
701- // Replace with the content nodes
702- newNodes . push ( ...replacements . get ( node ) ! )
703- } else {
704- newNodes . push ( node )
705- // Recursively process nested fragments
706- this . _replaceNodesInFragments ( node , replacements )
707- }
708- }
709- block . nodes = newNodes
710- } else if ( block . nodes instanceof Node && replacements . has ( block . nodes ) ) {
711- // Replace single node with its content
712- const replacement = replacements . get ( block . nodes ) !
713- block . nodes = replacement . length === 1 ? replacement [ 0 ] : replacement
714- } else {
715- this . _replaceNodesInFragments ( block . nodes , replacements )
716- }
717- }
671+ this . _updateSlotNodes ( slotReplacements )
718672 }
719673
720674 /**
@@ -814,6 +768,13 @@ export class VueElement extends VueElementBase<
814768 this . _app = this . _instance = null
815769 }
816770
771+ /**
772+ * Only called when shadowRoot is false
773+ */
774+ protected _updateSlotNodes ( replacements : Map < Node , Node [ ] > ) : void {
775+ // do nothing
776+ }
777+
817778 private _createVNode ( ) : VNode < any , any > {
818779 const baseProps : VNodeProps = { }
819780 if ( ! this . shadowRoot ) {
0 commit comments