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'
function parseWithVOn(template: string, options: CompilerOptions = {}) {
const ast = parse(template, options)
transform(ast, {
- nodeTransforms: [transformExpression, transformElement],
+ nodeTransforms: [transformExpression, transformElement, transformFor],
directiveTransforms: {
on: transformOn,
},
expect(root.cached).toBe(1)
})
+ test('unicode identifier should not be cached (v-for)', () => {
+ const { root } = parseWithVOn(
+ `<div v-for="项 in items" :key="value"><div v-on:click="foo(项)"/></div>`,
+ {
+ prefixIdentifiers: true,
+ cacheHandlers: true,
+ },
+ )
+ expect(root.cached).toBe(0)
+ })
+
test('inline function expression handler', () => {
const { root, node } = parseWithVOn(`<div v-on:click="() => foo()" />`, {
prefixIdentifiers: true,
}
}
-const nonIdentifierRE = /^\d|[^\$\w]/
+const nonIdentifierRE = /^\d|[^\$\w\xA0-\uFFFF]/
export const isSimpleIdentifier = (name: string): boolean =>
!nonIdentifierRE.test(name)