Fix self-closing style tags in vue (#4108)

master
Lucas Duailibe 2018-03-06 13:06:09 -03:00 committed by GitHub
commit f6f6f2e2ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 36 additions and 1 deletions

View File

@ -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;
}

View File

@ -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>

View File

@ -0,0 +1,5 @@
<template>
<span :class="$style.root"><slot /></span>
</template>
<style src="./style.css" module />