Skip to content

Commit

Permalink
fix: don't camelize attributes for plain elements (#3750)
Browse files Browse the repository at this point in the history
Co-authored-by: Ray <[email protected]>
Co-authored-by: Johnson Chu <[email protected]>
3 people authored Nov 29, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 32fd1ee commit 1789690
Showing 2 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/language-core/src/generators/template.ts
Original file line number Diff line number Diff line change
@@ -1260,6 +1260,7 @@ export function generate(
if (
(!prop.arg || (prop.arg.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION && prop.arg.isStatic)) // isStatic
&& hyphenateAttr(attrNameText) === attrNameText
&& !nativeTags.has(node.tag)
&& !vueCompilerOptions.htmlAttributes.some(pattern => minimatch(attrNameText!, pattern))
) {
attrNameText = camelize(attrNameText);
@@ -1366,6 +1367,7 @@ export function generate(

if (
hyphenateAttr(prop.name) === prop.name
&& !nativeTags.has(node.tag)
&& !vueCompilerOptions.htmlAttributes.some(pattern => minimatch(attrNameText!, pattern))
) {
attrNameText = camelize(prop.name);
19 changes: 19 additions & 0 deletions test-workspace/tsc/vue3_strictTemplate/dataAttributes/main.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<template>
<div>
<svg>
<path stroke="#efefef" stroke-width="123" pathLength="10" />
<path stroke="#efefef" :stroke-width="123" :pathLength="10" />
</svg>
<foo stroke-width="123" />
</div>
</template>

<script setup lang="ts">
import { defineComponent } from 'vue';
const Foo = defineComponent({
props: {
strokeWidth: { type: String, required: true },
}
});
</script>

0 comments on commit 1789690

Please sign in to comment.