diff --git a/packages/compiler-core/__tests__/transforms/vOn.spec.ts b/packages/compiler-core/__tests__/transforms/vOn.spec.ts index b1c37e3f74e..27d5027533b 100644 --- a/packages/compiler-core/__tests__/transforms/vOn.spec.ts +++ b/packages/compiler-core/__tests__/transforms/vOn.spec.ts @@ -10,6 +10,7 @@ import { baseParse as parse, transform, } from '../../src' +import { transformFor } from '../../src/transforms/vFor' import { transformOn } from '../../src/transforms/vOn' import { transformElement } from '../../src/transforms/transformElement' import { transformExpression } from '../../src/transforms/transformExpression' @@ -17,7 +18,7 @@ import { transformExpression } from '../../src/transforms/transformExpression' function parseWithVOn(template: string, options: CompilerOptions = {}) { const ast = parse(template, options) transform(ast, { - nodeTransforms: [transformExpression, transformElement], + nodeTransforms: [transformExpression, transformElement, transformFor], directiveTransforms: { on: transformOn, }, @@ -602,6 +603,17 @@ describe('compiler: transform v-on', () => { expect(root.cached).toBe(1) }) + test('unicode identifier should not be cached (v-for)', () => { + const { root } = parseWithVOn( + `
`, + { + prefixIdentifiers: true, + cacheHandlers: true, + }, + ) + expect(root.cached).toBe(0) + }) + test('inline function expression handler', () => { const { root, node } = parseWithVOn(`
`, { prefixIdentifiers: true, diff --git a/packages/compiler-core/src/utils.ts b/packages/compiler-core/src/utils.ts index aa596028440..561c6357864 100644 --- a/packages/compiler-core/src/utils.ts +++ b/packages/compiler-core/src/utils.ts @@ -62,7 +62,7 @@ export function isCoreComponent(tag: string): symbol | void { } } -const nonIdentifierRE = /^\d|[^\$\w]/ +const nonIdentifierRE = /^\d|[^\$\w\xA0-\uFFFF]/ export const isSimpleIdentifier = (name: string): boolean => !nonIdentifierRE.test(name)