From: HcySunYang Date: Thu, 25 Mar 2021 21:24:18 +0000 (+0800) Subject: fix(compiler-core): allow unicode to appear in identifiers (#3443) X-Git-Tag: v3.0.8~18 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ebedcccdc04d8cda40f7a3b69354acfdda265c74;p=thirdparty%2Fvuejs%2Fcore.git fix(compiler-core): allow unicode to appear in identifiers (#3443) fix #3440 --- diff --git a/packages/compiler-core/__tests__/transforms/vModel.spec.ts b/packages/compiler-core/__tests__/transforms/vModel.spec.ts index 119624cda8..3c429b3191 100644 --- a/packages/compiler-core/__tests__/transforms/vModel.spec.ts +++ b/packages/compiler-core/__tests__/transforms/vModel.spec.ts @@ -507,6 +507,13 @@ describe('compiler: transform v-model', () => { ) }) + test('allow unicode', () => { + const onError = jest.fn() + parseWithVModel('', { onError }) + + expect(onError).toHaveBeenCalledTimes(0) + }) + test('used on scope variable', () => { const onError = jest.fn() parseWithVModel('', { diff --git a/packages/compiler-core/src/utils.ts b/packages/compiler-core/src/utils.ts index 107bb0f6c1..b65c812a6e 100644 --- a/packages/compiler-core/src/utils.ts +++ b/packages/compiler-core/src/utils.ts @@ -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())