mirror of https://github.com/vuejs/core.git
Merge 0fc9925dce
into 56be3dd4db
This commit is contained in:
commit
ae1b3cb6f7
|
@ -149,7 +149,8 @@ export function setRef(
|
|||
warn('Invalid template ref type:', ref, `(${typeof ref})`)
|
||||
}
|
||||
}
|
||||
if (value) {
|
||||
|
||||
if (value || (vnode.transition && !vnode.transition.persisted)) {
|
||||
// #1789: for non-null values, set them after render
|
||||
// null values means this is unmount and it should not overwrite another
|
||||
// ref with the same key
|
||||
|
|
|
@ -297,6 +297,57 @@ describe('e2e: TransitionGroup', () => {
|
|||
E2E_TIMEOUT,
|
||||
)
|
||||
|
||||
test(
|
||||
'ref',
|
||||
async () => {
|
||||
await page().evaluate(() => {
|
||||
const { createApp, ref } = (window as any).Vue
|
||||
createApp({
|
||||
template: `
|
||||
<div id="container">
|
||||
<transition-group name="group">
|
||||
<div v-for="item in items" :key="item" ref="itemRef" class="test">{{item}}</div>
|
||||
</transition-group>
|
||||
</div>
|
||||
<button id="toggleBtn" @click="click">button</button>
|
||||
`,
|
||||
setup: () => {
|
||||
const items = ref(['a', 'b', 'c'])
|
||||
const click = () => (items.value = ['d', 'b', 'a'])
|
||||
const itemRef = ref()
|
||||
return { click, items, itemRef }
|
||||
},
|
||||
}).mount('#app')
|
||||
})
|
||||
expect(await html('#container')).toBe(
|
||||
`<div class="test">a</div>` +
|
||||
`<div class="test">b</div>` +
|
||||
`<div class="test">c</div>`,
|
||||
)
|
||||
|
||||
expect(await htmlWhenTransitionStart()).toBe(
|
||||
`<div class="test group-enter-from group-enter-active">d</div>` +
|
||||
`<div class="test">b</div>` +
|
||||
`<div class="test group-move" style="">a</div>` +
|
||||
`<div class="test group-leave-from group-leave-active group-move" style="">c</div>`,
|
||||
)
|
||||
await nextFrame()
|
||||
expect(await html('#container')).toBe(
|
||||
`<div class="test group-enter-active group-enter-to">d</div>` +
|
||||
`<div class="test">b</div>` +
|
||||
`<div class="test group-move" style="">a</div>` +
|
||||
`<div class="test group-leave-active group-move group-leave-to" style="">c</div>`,
|
||||
)
|
||||
await transitionFinish(duration * 2)
|
||||
expect(await html('#container')).toBe(
|
||||
`<div class="test">d</div>` +
|
||||
`<div class="test">b</div>` +
|
||||
`<div class="test" style="">a</div>`,
|
||||
)
|
||||
},
|
||||
E2E_TIMEOUT,
|
||||
)
|
||||
|
||||
test(
|
||||
'dynamic name',
|
||||
async () => {
|
||||
|
|
Loading…
Reference in New Issue