Skip to content

Commit b5a660d

Browse files
committed
fix html-end-tags failing on self-closing elements
1 parent 7b9df95 commit b5a660d

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

lib/rules/html-end-tags.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ function create (context) {
2626
VElement (node) {
2727
const name = node.name
2828
const isVoid = utils.isHtmlVoidElementName(name)
29+
const isSelfClosing = node.startTag.selfClosing
2930
const hasEndTag = node.endTag != null
3031

3132
if (isVoid && hasEndTag) {
@@ -37,7 +38,7 @@ function create (context) {
3738
fix: (fixer) => fixer.remove(node.endTag)
3839
})
3940
}
40-
if (!isVoid && !hasEndTag) {
41+
if (!isVoid && !hasEndTag && !isSelfClosing) {
4142
context.report({
4243
node: node.startTag,
4344
loc: node.startTag.loc,

tests/lib/rules/html-end-tags.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@ tester.run('html-end-tags', rule, {
4646
{
4747
filename: 'test.vue',
4848
code: '<template><div><img></div></template>'
49+
},
50+
{
51+
filename: 'test.vue',
52+
code: '<template><div><self-closing-custom-element/></div></template>'
53+
},
54+
{
55+
filename: 'test.vue',
56+
code: '<template><div><div/></div></template>'
4957
}
5058
],
5159
invalid: [

0 commit comments

Comments
 (0)