File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1313,6 +1313,47 @@ function runSharedTests(deferMode: boolean): void {
13131313 expect ( root . innerHTML ) . toBe ( '<div>foo</div><!--if-->' )
13141314 } )
13151315
1316+ test ( 'should remove teleport with insertion parent when toggled off' , async ( ) => {
1317+ const root = document . createElement ( 'div' )
1318+ const target = document . createElement ( 'div' )
1319+ const show = ref ( true )
1320+
1321+ const { mount } = define ( {
1322+ setup ( ) {
1323+ return createIf (
1324+ ( ) => show . value ,
1325+ ( ) => {
1326+ const n0 = template ( '<div></div>' ) ( )
1327+ setInsertionState ( n0 as any , null , 0 , true )
1328+ createComponent (
1329+ VaporTeleport ,
1330+ {
1331+ to : ( ) => target ,
1332+ } ,
1333+ {
1334+ default : ( ) => template ( '<input>' ) ( ) ,
1335+ } ,
1336+ )
1337+ return n0
1338+ } ,
1339+ )
1340+ } ,
1341+ } ) . create ( )
1342+
1343+ mount ( root )
1344+
1345+ expect ( root . innerHTML ) . toBe (
1346+ '<div><!--teleport start--><!--teleport end--></div><!--if-->' ,
1347+ )
1348+ expect ( target . innerHTML ) . toBe ( '<input>' )
1349+
1350+ show . value = false
1351+ await nextTick ( )
1352+
1353+ expect ( root . innerHTML ) . toBe ( '<!--if-->' )
1354+ expect ( target . innerHTML ) . toBe ( '' )
1355+ } )
1356+
13161357 test ( 'unmount previous sibling node inside target node' , async ( ) => {
13171358 const root = document . createElement ( 'div' )
13181359 const parentShow = ref ( false )
Original file line number Diff line number Diff line change @@ -331,6 +331,7 @@ export function createComponent(
331331 // teleport
332332 if ( isVaporTeleport ( component ) ) {
333333 const frag = component . process ( rawProps ! , rawSlots ! )
334+ onScopeDispose ( ( ) => remove ( frag ) , true )
334335 if ( ! isHydrating ) {
335336 if ( _insertionParent ) insert ( frag , _insertionParent , _insertionAnchor )
336337 } else {
You can’t perform that action at this time.
0 commit comments