Skip to content

Commit 3ea9644

Browse files
authored
fix(compiler-core): allow unicode to appear in simple identifiers (#6765)
close #6367
1 parent 4c74302 commit 3ea9644

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

packages/compiler-core/__tests__/transforms/vOn.spec.ts

+13-1
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,15 @@ import {
1010
baseParse as parse,
1111
transform,
1212
} from '../../src'
13+
import { transformFor } from '../../src/transforms/vFor'
1314
import { transformOn } from '../../src/transforms/vOn'
1415
import { transformElement } from '../../src/transforms/transformElement'
1516
import { transformExpression } from '../../src/transforms/transformExpression'
1617

1718
function parseWithVOn(template: string, options: CompilerOptions = {}) {
1819
const ast = parse(template, options)
1920
transform(ast, {
20-
nodeTransforms: [transformExpression, transformElement],
21+
nodeTransforms: [transformExpression, transformElement, transformFor],
2122
directiveTransforms: {
2223
on: transformOn,
2324
},
@@ -602,6 +603,17 @@ describe('compiler: transform v-on', () => {
602603
expect(root.cached).toBe(1)
603604
})
604605

606+
test('unicode identifier should not be cached (v-for)', () => {
607+
const { root } = parseWithVOn(
608+
`<div v-for="项 in items" :key="value"><div v-on:click="foo(项)"/></div>`,
609+
{
610+
prefixIdentifiers: true,
611+
cacheHandlers: true,
612+
},
613+
)
614+
expect(root.cached).toBe(0)
615+
})
616+
605617
test('inline function expression handler', () => {
606618
const { root, node } = parseWithVOn(`<div v-on:click="() => foo()" />`, {
607619
prefixIdentifiers: true,

packages/compiler-core/src/utils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export function isCoreComponent(tag: string): symbol | void {
6262
}
6363
}
6464

65-
const nonIdentifierRE = /^\d|[^\$\w]/
65+
const nonIdentifierRE = /^\d|[^\$\w\xA0-\uFFFF]/
6666
export const isSimpleIdentifier = (name: string): boolean =>
6767
!nonIdentifierRE.test(name)
6868

0 commit comments

Comments
 (0)