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

feat(html): treat capital element as custom element #5395

Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 5 additions & 1 deletion src/language-html/utils.js
Expand Up @@ -252,7 +252,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 @@ -960,6 +960,13 @@ exports[`self_closing.vue - vue-verify 1`] = `
<script>
foo( )
</script>

<div class="container">
<HomeH />
<HomeA />
<HomeX />
<HomeY />
</div>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<template>
<div />
Expand All @@ -969,6 +976,13 @@ foo( )
foo();
</script>

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

`;

exports[`self_closing.vue - vue-verify 2`] = `
Expand All @@ -979,6 +993,13 @@ exports[`self_closing.vue - vue-verify 2`] = `
<script>
foo( )
</script>

<div class="container">
<HomeH />
<HomeA />
<HomeX />
<HomeY />
</div>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<template>
<div />
Expand All @@ -988,6 +1009,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>