Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(html): preserve content for <template> with unknown lang #5388

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/language-html/utils.js
Expand Up @@ -40,6 +40,15 @@ function hasPrettierIgnore(path) {
return false;
}

if (
node.type === "element" &&
node.fullName === "template" &&
node.attrMap.lang &&
node.attrMap.lang !== "html"
) {
return true;
}

// TODO: handle non-text children in <pre>
if (
isPreLikeNode(node) &&
Expand Down
30 changes: 30 additions & 0 deletions tests/html_vue/__snapshots__/jsfmt.spec.js.snap
Expand Up @@ -1140,6 +1140,36 @@ exports[`template.vue - vue-verify 2`] = `

`;

exports[`template-lang.vue - vue-verify 1`] = `
<template lang="pug">
.test
#foo
.bla
</template>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<template lang="pug">
.test
#foo
.bla
</template>

`;

exports[`template-lang.vue - vue-verify 2`] = `
<template lang="pug">
.test
#foo
.bla
</template>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<template lang="pug">
.test
#foo
.bla
</template>

`;

exports[`test.vue - vue-verify 1`] = `
<script>
</script>
Expand Down
5 changes: 5 additions & 0 deletions tests/html_vue/template-lang.vue
@@ -0,0 +1,5 @@
<template lang="pug">
.test
#foo
.bla
</template>