Skip to content

Commit

Permalink
fix: fix formatting v-bind.modifier
Browse files Browse the repository at this point in the history
  • Loading branch information
g-plane committed Oct 31, 2024
1 parent 8f9baea commit 8bc2c58
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 3 deletions.
10 changes: 7 additions & 3 deletions markup_fmt/src/printer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1587,11 +1587,15 @@ impl<'s> DocGen<'s> for VueDirective<'s> {
is_v_bind = true;
if let Some(arg_and_modifiers) = self.arg_and_modifiers {
docs.push(if let Some(VBindStyle::Short) = ctx.options.v_bind_style {
Doc::text(":")
if arg_and_modifiers.starts_with(':') {
Doc::text("")
} else {
Doc::text("v-bind")
}
} else {
Doc::text("v-bind:")
Doc::text("v-bind")
});
docs.push(Doc::text(arg_and_modifiers.trim_start_matches(':')));
docs.push(Doc::text(arg_and_modifiers));
} else {
docs.push(Doc::text("v-bind"));
}
Expand Down
1 change: 1 addition & 0 deletions markup_fmt/tests/fmt/vue/v-bind/fixture.default.snap
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ source: markup_fmt/tests/fmt.rs
<button v-bind:type=""></button>
<button v-bind:type.sync=""></button>
<button v-bind></button>
<button v-bind.sync></button>
</template>
1 change: 1 addition & 0 deletions markup_fmt/tests/fmt/vue/v-bind/fixture.long.snap
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ source: markup_fmt/tests/fmt.rs
<button v-bind:type=""></button>
<button v-bind:type.sync=""></button>
<button v-bind></button>
<button v-bind.sync></button>
</template>
1 change: 1 addition & 0 deletions markup_fmt/tests/fmt/vue/v-bind/fixture.short.snap
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ source: markup_fmt/tests/fmt.rs
<button :type=""></button>
<button :type.sync=""></button>
<button v-bind></button>
<button v-bind.sync></button>
</template>
1 change: 1 addition & 0 deletions markup_fmt/tests/fmt/vue/v-bind/fixture.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
<button v-bind:type=""></button>
<button v-bind:type.sync=""></button>
<button v-bind></button>
<button v-bind.sync></button>
</template>

0 comments on commit 8bc2c58

Please sign in to comment.