@@ -1722,6 +1722,107 @@ describe('e2e: Transition', () => {
17221722 } ,
17231723 E2E_TIMEOUT ,
17241724 )
1725+
1726+ // #13153
1727+ test (
1728+ 'move kept-alive node before v-show transition leave finishes' ,
1729+ async ( ) => {
1730+ await page ( ) . evaluate ( ( ) => {
1731+ const { createApp, ref } = ( window as any ) . Vue
1732+ const show = ref ( true )
1733+ createApp ( {
1734+ template : `
1735+ <div id="container">
1736+ <KeepAlive :include="['Comp1', 'Comp2']">
1737+ <component :is="state === 1 ? 'Comp1' : 'Comp2'"/>
1738+ </KeepAlive>
1739+ </div>
1740+ <button id="toggleBtn" @click="click">button</button>
1741+ ` ,
1742+ setup : ( ) => {
1743+ const state = ref ( 1 )
1744+ const click = ( ) => ( state . value = state . value === 1 ? 2 : 1 )
1745+ return { state, click }
1746+ } ,
1747+ components : {
1748+ Comp1 : {
1749+ components : {
1750+ Item : {
1751+ name : 'Item' ,
1752+ setup ( ) {
1753+ return { show }
1754+ } ,
1755+ template : `
1756+ <Transition name="test">
1757+ <div v-show="show" >
1758+ <h2>{{ show ? "I should show" : "I shouldn't show " }}</h2>
1759+ </div>
1760+ </Transition>
1761+ ` ,
1762+ } ,
1763+ } ,
1764+ name : 'Comp1' ,
1765+ setup ( ) {
1766+ const toggle = ( ) => ( show . value = ! show . value )
1767+ return { show, toggle }
1768+ } ,
1769+ template : `
1770+ <Item />
1771+ <h2>This is page1</h2>
1772+ <button id="changeShowBtn" @click="toggle">{{ show }}</button>
1773+ ` ,
1774+ } ,
1775+ Comp2 : {
1776+ name : 'Comp2' ,
1777+ template : `<h2>This is page2</h2>` ,
1778+ } ,
1779+ } ,
1780+ } ) . mount ( '#app' )
1781+ } )
1782+
1783+ expect ( await html ( '#container' ) ) . toBe (
1784+ `<div><h2>I should show</h2></div>` +
1785+ `<h2>This is page1</h2>` +
1786+ `<button id="changeShowBtn">true</button>` ,
1787+ )
1788+
1789+ // trigger v-show transition leave
1790+ await click ( '#changeShowBtn' )
1791+ await nextTick ( )
1792+ expect ( await html ( '#container' ) ) . toBe (
1793+ `<div class="test-leave-from test-leave-active"><h2>I shouldn't show </h2></div>` +
1794+ `<h2>This is page1</h2>` +
1795+ `<button id="changeShowBtn">false</button>` ,
1796+ )
1797+
1798+ // switch to page2, before leave finishes
1799+ // expect v-show element's display to be none
1800+ await click ( '#toggleBtn' )
1801+ await nextTick ( )
1802+ expect ( await html ( '#container' ) ) . toBe (
1803+ `<div class="test-leave-from test-leave-active" style="display: none;"><h2>I shouldn't show </h2></div>` +
1804+ `<h2>This is page2</h2>` ,
1805+ )
1806+
1807+ // switch back to page1
1808+ // expect v-show element's display to be none
1809+ await click ( '#toggleBtn' )
1810+ await nextTick ( )
1811+ expect ( await html ( '#container' ) ) . toBe (
1812+ `<div class="test-enter-from test-enter-active" style="display: none;"><h2>I shouldn't show </h2></div>` +
1813+ `<h2>This is page1</h2>` +
1814+ `<button id="changeShowBtn">false</button>` ,
1815+ )
1816+
1817+ await transitionFinish ( )
1818+ expect ( await html ( '#container' ) ) . toBe (
1819+ `<div class="" style="display: none;"><h2>I shouldn't show </h2></div>` +
1820+ `<h2>This is page1</h2>` +
1821+ `<button id="changeShowBtn">false</button>` ,
1822+ )
1823+ } ,
1824+ E2E_TIMEOUT ,
1825+ )
17251826 } )
17261827
17271828 describe ( 'transition with Suspense' , ( ) => {
0 commit comments