Skip to content

Commit

Permalink
feat(html): treat capital element as custom element (#5395)
Browse files Browse the repository at this point in the history
Custom element: keep it on its own line if both leading/trailing line breaks exist
  • Loading branch information
ikatyang committed Nov 9, 2018
1 parent 0228863 commit 9acb029
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/language-html/utils.js
Expand Up @@ -254,7 +254,11 @@ function isCustomElementWithSurroundingLineBreak(node) {
}

function isCustomElement(node) {
return node.type === "element" && !node.namespace && node.name.includes("-");
return (
node.type === "element" &&
!node.namespace &&
(node.name.includes("-") || /[A-Z]/.test(node.name[0]))
);
}

function hasSurroundingLineBreak(node) {
Expand Down
5 changes: 4 additions & 1 deletion tests/html_attributes/__snapshots__/jsfmt.spec.js.snap
Expand Up @@ -141,7 +141,10 @@ and HTML5 Apps. It also documents Mozilla products, like Firefox OS."
data-index-number="12314"
data-parent="cars"
></article>
<X> </X> <X a="1"> </X> <X a="1" b="2"> </X> <X a="1" b="2" c="3"> </X>
<X> </X>
<X a="1"> </X>
<X a="1" b="2"> </X>
<X a="1" b="2" c="3"> </X>
<p
class="
foo
Expand Down
28 changes: 28 additions & 0 deletions tests/html_vue/__snapshots__/jsfmt.spec.js.snap
Expand Up @@ -1034,6 +1034,13 @@ exports[`self_closing.vue - vue-verify 1`] = `
<script>
foo( )
</script>
<div class="container">
<HomeH />
<HomeA />
<HomeX />
<HomeY />
</div>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<template>
<div />
Expand All @@ -1043,6 +1050,13 @@ foo( )
foo();
</script>
<div class="container">
<HomeH />
<HomeA />
<HomeX />
<HomeY />
</div>
`;
exports[`self_closing.vue - vue-verify 2`] = `
Expand All @@ -1053,6 +1067,13 @@ exports[`self_closing.vue - vue-verify 2`] = `
<script>
foo( )
</script>
<div class="container">
<HomeH />
<HomeA />
<HomeX />
<HomeY />
</div>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<template>
<div />
Expand All @@ -1062,6 +1083,13 @@ foo( )
foo();
</script>
<div class="container">
<HomeH />
<HomeA />
<HomeX />
<HomeY />
</div>
`;
exports[`self_closing_style.vue - vue-verify 1`] = `
Expand Down
7 changes: 7 additions & 0 deletions tests/html_vue/self_closing.vue
Expand Up @@ -5,3 +5,10 @@
<script>
foo( )
</script>

<div class="container">
<HomeH />
<HomeA />
<HomeX />
<HomeY />
</div>

0 comments on commit 9acb029

Please sign in to comment.