Skip to content

fix(runtime-core): avoid set ref side effect #11673

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/runtime-core/src/rendererTemplateRef.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
} from '@vue/shared'
import { isAsyncWrapper } from './apiAsyncComponent'
import { warn } from './warning'
import { isRef } from '@vue/reactivity'
import { isRef, toRaw } from '@vue/reactivity'
import { ErrorCodes, callWithErrorHandling } from './errorHandling'
import type { SchedulerJob } from './scheduler'
import { queuePostRenderEffect } from './renderer'
Expand Down Expand Up @@ -86,7 +86,7 @@ export function setRef(
if (rawRef.f) {
const existing = _isString
? hasOwn(setupState, ref)
? setupState[ref]
? toRaw(setupState[ref])
: refs[ref]
: ref.value
if (isUnmount) {
Expand Down
52 changes: 52 additions & 0 deletions packages/vue/__tests__/e2e/TransitionGroup.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -630,4 +630,56 @@ describe('e2e: TransitionGroup', () => {
},
E2E_TIMEOUT,
)

// #7754
test(
'inner children with 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,
)
})
Loading