Skip to content

Commit

Permalink
fix: ignore class, style attrs when v-bind exist
Browse files Browse the repository at this point in the history
close #2166
  • Loading branch information
johnsoncodehk committed Dec 25, 2022
1 parent 63b794a commit 275a95f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
11 changes: 11 additions & 0 deletions vue-language-tools/vue-language-core/src/generators/template.ts
Expand Up @@ -832,6 +832,17 @@ export function generate(
let classAttrNums = 0;
const unwritedExps: CompilerDOM.SimpleExpressionNode[] = [];

if (node.props.some(prop =>
prop.type === CompilerDOM.NodeTypes.DIRECTIVE
&& prop.name === 'bind'
&& !prop.arg
&& prop.exp?.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION
)) {
// fix https://github.com/johnsoncodehk/volar/issues/2166
styleAttrNums++;
classAttrNums++;
}

for (const prop of node.props) {
if (
prop.type === CompilerDOM.NodeTypes.DIRECTIVE
Expand Down
3 changes: 3 additions & 0 deletions vue-language-tools/vue-test-workspace/vue-tsc/#2166/main.vue
@@ -0,0 +1,3 @@
<template>
<div class="a" v-bind="{ class: {b: true} }" />
</template>

0 comments on commit 275a95f

Please sign in to comment.