Skip to content

Commit c6a4e36

Browse files
authored
fix(language-core): generate correct reference for v-on on <slot> (#4864)
1 parent 564aa84 commit c6a4e36

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

packages/language-core/lib/codegen/template/elementProps.ts

+4-5
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ export function* generateElementProps(
2525
suffix: string;
2626
}[]
2727
): Generator<Code> {
28-
const isIntrinsicElement = node.tagType === CompilerDOM.ElementTypes.ELEMENT || node.tagType === CompilerDOM.ElementTypes.TEMPLATE;
29-
const canCamelize = node.tagType === CompilerDOM.ElementTypes.COMPONENT;
28+
const isComponent = node.tagType === CompilerDOM.ElementTypes.COMPONENT;
3029

3130
for (const prop of props) {
3231
if (
@@ -38,7 +37,7 @@ export function* generateElementProps(
3837
&& !prop.arg.loc.source.startsWith('[')
3938
&& !prop.arg.loc.source.endsWith(']')
4039
) {
41-
if (isIntrinsicElement) {
40+
if (!isComponent) {
4241
yield `...{ `;
4342
yield* generateEventArg(ctx, prop.arg, true);
4443
yield `: `;
@@ -102,7 +101,7 @@ export function* generateElementProps(
102101
}
103102

104103
const shouldSpread = propName === 'style' || propName === 'class';
105-
const shouldCamelize = canCamelize
104+
const shouldCamelize = isComponent
106105
&& (!prop.arg || (prop.arg.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION && prop.arg.isStatic)) // isStatic
107106
&& hyphenateAttr(propName) === propName
108107
&& !options.vueCompilerOptions.htmlAttributes.some(pattern => minimatch(propName, pattern));
@@ -190,7 +189,7 @@ export function* generateElementProps(
190189
}
191190

192191
const shouldSpread = prop.name === 'style' || prop.name === 'class';
193-
const shouldCamelize = canCamelize
192+
const shouldCamelize = isComponent
194193
&& hyphenateAttr(prop.name) === prop.name
195194
&& !options.vueCompilerOptions.htmlAttributes.some(pattern => minimatch(prop.name, pattern));
196195

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<script setup lang="ts">
2+
const bar = () => {}
3+
</script>
4+
5+
<template>
6+
<slot @bar="bar"></slot>
7+
</template>

0 commit comments

Comments
 (0)