]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(compiler-core): fix v-on with modifiers on inline expression of undefined (#9866)
author白雾三语 <32354856+baiwusanyu-c@users.noreply.github.com>
Tue, 19 Dec 2023 09:08:46 +0000 (17:08 +0800)
committerGitHub <noreply@github.com>
Tue, 19 Dec 2023 09:08:46 +0000 (17:08 +0800)
close #9865
improve isMemberExpression check for undefined

packages/compiler-core/__tests__/utils.spec.ts
packages/compiler-core/src/utils.ts

index 45fa46fea7a60d28a367fe5c4f1a886280eb530e..f2ea70cc51d5a9da08e43bdca0d4e972f9ae275d 100644 (file)
@@ -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)
   })
 })
 
index baffe5086f621f3dff376ebe14704bbc55e5f225..fe4141507bcb185395469397b1ed52711fbe558f 100644 (file)
@@ -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