Skip to content

Commit

Permalink
Fix self-closing style tags in vue (#4108)
Browse files Browse the repository at this point in the history
  • Loading branch information
duailibe authored Mar 6, 2018
2 parents 8ab09cc + 550904d commit f6f6f2e
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/language-vue/embed.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const hardline = docBuilders.hardline;
function embed(path, print, textToDoc, options) {
const node = path.getValue();
const parent = path.getParentNode();
if (!parent || parent.tag !== "root") {
if (!parent || parent.tag !== "root" || node.unary) {
return null;
}

Expand Down
30 changes: 30 additions & 0 deletions tests/vue_examples/__snapshots__/jsfmt.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,36 @@ foo();
`;

exports[`self_closing_style.vue 1`] = `
<template>
<span :class="$style.root"><slot /></span>
</template>
<style src="./style.css" module />
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<template>
<span :class="$style.root"><slot /></span>
</template>
<style src="./style.css" module />
`;

exports[`self_closing_style.vue 2`] = `
<template>
<span :class="$style.root"><slot /></span>
</template>
<style src="./style.css" module />
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<template>
<span :class="$style.root"><slot /></span>
</template>
<style src="./style.css" module />
`;

exports[`test.vue 1`] = `
<script>
</script>
Expand Down
5 changes: 5 additions & 0 deletions tests/vue_examples/self_closing_style.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<template>
<span :class="$style.root"><slot /></span>
</template>

<style src="./style.css" module />

0 comments on commit f6f6f2e

Please sign in to comment.