Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(compiler-core): allow unicode to appear in simple identifiers #6765

Merged
merged 5 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions packages/compiler-core/__tests__/transforms/vOn.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,18 @@ describe('compiler: transform v-on', () => {
expect(root.cached).toBe(1)
})

test('should not be cached if the function references closure variables (v-for, v-slot)', () => {
godxiaoji marked this conversation as resolved.
Show resolved Hide resolved
const { root } = parseWithVOn(
`<div v-for="value in items" :key="value"><div v-on:click="foo(value)"/></div>`,
{
prefixIdentifiers: true,
cacheHandlers: true
}
)
expect(root.cached).not.toBe(2)
expect(root.cached).toBe(1)
})

test('inline function expression handler', () => {
const { root, node } = parseWithVOn(`<div v-on:click="() => foo()" />`, {
prefixIdentifiers: true,
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 @@ -65,7 +65,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)

Expand Down