]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(compiler-core): allow unicode to appear in identifiers (#3443)
authorHcySunYang <HcySunYang@outlook.com>
Thu, 25 Mar 2021 21:24:18 +0000 (05:24 +0800)
committerGitHub <noreply@github.com>
Thu, 25 Mar 2021 21:24:18 +0000 (17:24 -0400)
fix #3440

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

index 119624cda8ca71be4921745c82e157dbbf79787f..3c429b3191574c2da7502ae12edf1ffafa171030 100644 (file)
@@ -507,6 +507,13 @@ describe('compiler: transform v-model', () => {
       )
     })
 
+    test('allow unicode', () => {
+      const onError = jest.fn()
+      parseWithVModel('<span v-model="变.量" />', { onError })
+
+      expect(onError).toHaveBeenCalledTimes(0)
+    })
+
     test('used on scope variable', () => {
       const onError = jest.fn()
       parseWithVModel('<span v-for="i in list" v-model="i" />', {
index 107bb0f6c1426014f473dbbf1ca8e806a6a799ed..b65c812a6e4e923d79f792b40b1204197089f1fa 100644 (file)
@@ -56,7 +56,7 @@ const nonIdentifierRE = /^\d|[^\$\w]/
 export const isSimpleIdentifier = (name: string): boolean =>
   !nonIdentifierRE.test(name)
 
-const memberExpRE = /^[A-Za-z_$][\w$]*(?:\s*\.\s*[A-Za-z_$][\w$]*|\[[^\]]+\])*$/
+const memberExpRE = /^[A-Za-z_$\xA0-\uFFFF][\w$\xA0-\uFFFF]*(?:\s*\.\s*[A-Za-z_$\xA0-\uFFFF][\w$\xA0-\uFFFF]*|\[[^\]]+\])*$/
 export const isMemberExpression = (path: string): boolean => {
   if (!path) return false
   return memberExpRE.test(path.trim())