Skip to content

Commit 27168fa

Browse files
fix(runtime-core): add patchFlag to element containing ref attributes
1 parent b775b71 commit 27168fa

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

packages/compiler-core/__tests__/transforms/transformElement.spec.ts

+8
Original file line numberDiff line numberDiff line change
@@ -991,6 +991,14 @@ describe('compiler: element transform', () => {
991991
expect(node.patchFlag).toBe(genFlagText(PatchFlags.NEED_PATCH))
992992
})
993993

994+
// #9239
995+
test('NEED_PATCH (vfor ref)', () => {
996+
const { node } = parseWithBind(
997+
`<div v-for="item in 3" :key="3" ref="foo" />`
998+
)
999+
expect(node.patchFlag).toBe(genFlagText(PatchFlags.NEED_PATCH))
1000+
})
1001+
9941002
test('NEED_PATCH (custom directives)', () => {
9951003
const { node } = parseWithBind(`<div v-foo />`)
9961004
expect(node.patchFlag).toBe(genFlagText(PatchFlags.NEED_PATCH))

packages/compiler-core/src/transforms/transformElement.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,7 @@ export function buildProps(
747747
}
748748
}
749749
if (
750-
!shouldUseBlock &&
750+
!(shouldUseBlock && !hasRef) &&
751751
(patchFlag === 0 || patchFlag === PatchFlags.HYDRATE_EVENTS) &&
752752
(hasRef || hasVnodeHook || runtimeDirectives.length > 0)
753753
) {

0 commit comments

Comments
 (0)