fix(compiler-core): fix scope var reference check for v-on expressions
fix #2564
This commit is contained in:
parent
e41b46c396
commit
9db7095962
@ -521,6 +521,21 @@ describe('compiler: transform component slots', () => {
|
|||||||
</Comp>`,
|
</Comp>`,
|
||||||
true
|
true
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// #2564
|
||||||
|
assertDynamicSlots(
|
||||||
|
`<div v-for="i in list">
|
||||||
|
<Comp v-slot="bar"><button @click="fn(i)" /></Comp>
|
||||||
|
</div>`,
|
||||||
|
true
|
||||||
|
)
|
||||||
|
|
||||||
|
assertDynamicSlots(
|
||||||
|
`<div v-for="i in list">
|
||||||
|
<Comp v-slot="bar"><button @click="fn()" /></Comp>
|
||||||
|
</div>`,
|
||||||
|
false
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('named slot with v-if', () => {
|
test('named slot with v-if', () => {
|
||||||
|
@ -79,7 +79,12 @@ export const transformOn: DirectiveTransform = (
|
|||||||
// process the expression since it's been skipped
|
// process the expression since it's been skipped
|
||||||
if (!__BROWSER__ && context.prefixIdentifiers) {
|
if (!__BROWSER__ && context.prefixIdentifiers) {
|
||||||
isInlineStatement && context.addIdentifiers(`$event`)
|
isInlineStatement && context.addIdentifiers(`$event`)
|
||||||
exp = processExpression(exp, context, false, hasMultipleStatements)
|
exp = dir.exp = processExpression(
|
||||||
|
exp,
|
||||||
|
context,
|
||||||
|
false,
|
||||||
|
hasMultipleStatements
|
||||||
|
)
|
||||||
isInlineStatement && context.removeIdentifiers(`$event`)
|
isInlineStatement && context.removeIdentifiers(`$event`)
|
||||||
// with scope analysis, the function is hoistable if it has no reference
|
// with scope analysis, the function is hoistable if it has no reference
|
||||||
// to scope variables.
|
// to scope variables.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user