Skip to content

Commit 0f80d2d

Browse files
committed
chore: add test for #4361
1 parent b8f12f6 commit 0f80d2d

File tree

2 files changed

+33
-27
lines changed

2 files changed

+33
-27
lines changed

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

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,29 @@ export function* generateElementProps(
2323
const isIntrinsicElement = node.tagType === CompilerDOM.ElementTypes.ELEMENT || node.tagType === CompilerDOM.ElementTypes.TEMPLATE;
2424
const canCamelize = node.tagType === CompilerDOM.ElementTypes.COMPONENT;
2525

26-
if (isIntrinsicElement) {
27-
for (const prop of props) {
26+
27+
for (const prop of props) {
28+
if (
29+
prop.type === CompilerDOM.NodeTypes.DIRECTIVE
30+
&& prop.name === 'on'
31+
) {
2832
if (
29-
prop.type === CompilerDOM.NodeTypes.DIRECTIVE
30-
&& prop.name === 'on'
31-
&& prop.arg?.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION
33+
prop.arg?.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION
3234
&& !prop.arg.loc.source.startsWith('[')
3335
&& !prop.arg.loc.source.endsWith(']')
3436
) {
35-
yield `...{ `;
36-
yield* generateEventArg(ctx, prop.arg, true);
37-
yield `: `;
38-
yield* generateEventExpression(options, ctx, prop);
39-
yield `}, `;
37+
if (isIntrinsicElement) {
38+
yield `...{ `;
39+
yield* generateEventArg(ctx, prop.arg, true);
40+
yield `: `;
41+
yield* generateEventExpression(options, ctx, prop);
42+
yield `}, `;
43+
}
44+
else {
45+
yield `...{ '${camelize('on-' + prop.arg.loc.source)}': {} as any }, `;
46+
}
4047
}
41-
else if (
42-
prop.type === CompilerDOM.NodeTypes.DIRECTIVE
43-
&& prop.name === 'on'
44-
) {
48+
else {
4549
if (
4650
prop.arg?.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION
4751
&& prop.arg.loc.source.startsWith('[')
@@ -55,19 +59,6 @@ export function* generateElementProps(
5559
}
5660
}
5761
}
58-
else {
59-
for (const prop of props) {
60-
if (
61-
prop.type === CompilerDOM.NodeTypes.DIRECTIVE
62-
&& prop.name === 'on'
63-
&& prop.arg?.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION
64-
&& !prop.arg.loc.source.startsWith('[')
65-
&& !prop.arg.loc.source.endsWith(']')
66-
) {
67-
yield `...{ '${camelize('on-' + prop.arg.loc.source)}': {} as any }, `;
68-
}
69-
}
70-
}
7162

7263
for (const prop of props) {
7364
if (
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<script setup lang="ts">
2+
import { computed } from 'vue';
3+
4+
const props = defineProps<{ toggleEnter: boolean }>();
5+
6+
const eventName = computed(() => (props.toggleEnter ? 'enter' : null));
7+
8+
function handleEvent() {
9+
// noop
10+
}
11+
</script>
12+
13+
<template>
14+
<Transition @[eventName]="handleEvent" />
15+
</template>

0 commit comments

Comments
 (0)