Skip to content

Commit 0ffd1c6

Browse files
committed
fix(compiler): use underscores instead of colons for cached name
1 parent 941fb83 commit 0ffd1c6

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

packages/compiler/src/generators/component.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,10 @@ function processInlineHandlers(
126126
const isMemberExp = isMemberExpression(value, context.options)
127127
// cache inline handlers (fn expression or inline statement)
128128
if (!isMemberExp) {
129-
const name = getUniqueHandlerName(context, `_on_${prop.key.content}`)
129+
const name = getUniqueHandlerName(
130+
context,
131+
`_on_${prop.key.content.replace(':', '_')}`,
132+
)
130133
handlers.push({ name, value })
131134
ids[name] = null
132135
// replace the original prop value with the handler name

packages/compiler/test/transforms/__snapshots__/vOn.spec.ts.snap

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,14 @@ exports[`v-on > event modifier 1`] = `
5656
"
5757
`;
5858

59+
exports[`v-on > namespace event with Component 1`] = `
60+
"
61+
const _on_update_modelValue = () => {}
62+
const n0 = _createComponent(Comp, { "onUpdate:modelValue": () => _on_update_modelValue }, null, true)
63+
return n0
64+
"
65+
`;
66+
5967
exports[`v-on > should delegate event 1`] = `
6068
"
6169
const n0 = t0()

packages/compiler/test/transforms/vOn.spec.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,14 @@ describe('v-on', () => {
327327
)
328328
})
329329

330+
test('namespace event with Component', () => {
331+
const { code } = compileWithVOn(`<Comp onUpdate:modelValue={() => {}} />`)
332+
expect(code).toMatchSnapshot()
333+
expect(code).contains(
334+
'_createComponent(Comp, { "onUpdate:modelValue": () => _on_update_modelValue }, null, true)',
335+
)
336+
})
337+
330338
test('expression with type', () => {
331339
const { code } = compileWithVOn(`<div onClick={handleClick as any} />`)
332340
expect(code).toMatchInlineSnapshot(`

0 commit comments

Comments
 (0)