Skip to content

Commit a108b84

Browse files
committed
fix: camelize <slot> props
1 parent 26408a3 commit a108b84

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ export function* generateElementProps(
110110
}
111111

112112
const shouldSpread = propName === 'style' || propName === 'class';
113-
const shouldCamelize = isComponent && getShouldCamelize(options, prop, propName);
113+
const shouldCamelize = getShouldCamelize(options, node, prop, propName);
114114
const features = getPropsCodeFeatures(strictPropsCheck);
115115

116116
if (shouldSpread) {
@@ -174,7 +174,7 @@ export function* generateElementProps(
174174
}
175175

176176
const shouldSpread = prop.name === 'style' || prop.name === 'class';
177-
const shouldCamelize = isComponent && getShouldCamelize(options, prop, prop.name);
177+
const shouldCamelize = getShouldCamelize(options, node, prop, prop.name);
178178
const features = getPropsCodeFeatures(strictPropsCheck);
179179

180180
if (shouldSpread) {
@@ -297,13 +297,16 @@ function* generateAttrValue(
297297

298298
function getShouldCamelize(
299299
options: TemplateCodegenOptions,
300+
node: CompilerDOM.ElementNode,
300301
prop: CompilerDOM.AttributeNode | CompilerDOM.DirectiveNode,
301302
propName: string,
302303
) {
303304
return (
305+
node.tagType === CompilerDOM.ElementTypes.COMPONENT
306+
|| node.tagType === CompilerDOM.ElementTypes.SLOT
307+
) && (
304308
prop.type !== CompilerDOM.NodeTypes.DIRECTIVE
305-
|| !prop.arg
306-
|| (prop.arg.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION && prop.arg.isStatic)
309+
|| prop.arg?.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION && prop.arg.isStatic
307310
)
308311
&& hyphenateAttr(propName) === propName
309312
&& !options.vueCompilerOptions.htmlAttributes.some(pattern => isMatch(propName, pattern));

0 commit comments

Comments
 (0)