From bae79ddf8564a2da4a5365cfeb8d811990f42335 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E9=9B=BE=E4=B8=89=E8=AF=AD?= <32354856+baiwusanyu-c@users.noreply.github.com> Date: Tue, 19 Dec 2023 17:08:46 +0800 Subject: [PATCH] fix(compiler-core): fix v-on with modifiers on inline expression of undefined (#9866) close #9865 improve isMemberExpression check for undefined --- packages/compiler-core/__tests__/utils.spec.ts | 4 ++++ packages/compiler-core/src/utils.ts | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/compiler-core/__tests__/utils.spec.ts b/packages/compiler-core/__tests__/utils.spec.ts index 45fa46fea7a..f2ea70cc51d 100644 --- a/packages/compiler-core/__tests__/utils.spec.ts +++ b/packages/compiler-core/__tests__/utils.spec.ts @@ -122,6 +122,10 @@ describe('isMemberExpression', () => { expect(fn(`123[a]`)).toBe(true) expect(fn(`foo() as string`)).toBe(false) expect(fn(`a + b as string`)).toBe(false) + // #9865 + expect(fn('""')).toBe(false) + expect(fn('undefined')).toBe(false) + expect(fn('null')).toBe(false) }) }) diff --git a/packages/compiler-core/src/utils.ts b/packages/compiler-core/src/utils.ts index baffe5086f6..fe4141507bc 100644 --- a/packages/compiler-core/src/utils.ts +++ b/packages/compiler-core/src/utils.ts @@ -163,7 +163,7 @@ export const isMemberExpressionNode = __BROWSER__ return ( ret.type === 'MemberExpression' || ret.type === 'OptionalMemberExpression' || - ret.type === 'Identifier' + (ret.type === 'Identifier' && ret.name !== 'undefined') ) } catch (e) { return false