Skip to content

Commit

Permalink
fix(compiler-core): allow unicode to appear in identifiers (#3443)
Browse files Browse the repository at this point in the history
fix #3440
  • Loading branch information
HcySunYang committed Mar 25, 2021
1 parent 7715c49 commit ebedccc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions packages/compiler-core/__tests__/transforms/vModel.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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" />', {
Expand Down
2 changes: 1 addition & 1 deletion packages/compiler-core/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down

0 comments on commit ebedccc

Please sign in to comment.