Skip to content

Commit 18a3d8a

Browse files
committed
fix html-end-tags failing on self-closing elements
1 parent 6f4515f commit 18a3d8a

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

lib/rules/html-end-tags.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ function create (context) {
2626
VElement (node) {
2727
const name = node.name
2828
const isVoid = utils.isHtmlVoidElementName(name)
29-
const hasEndTag = node.endTag != null
3029
const isSelfClosing = node.startTag.selfClosing
30+
const hasEndTag = node.endTag != null
3131

3232
if (isVoid && hasEndTag) {
3333
context.report({
@@ -38,7 +38,7 @@ function create (context) {
3838
fix: (fixer) => fixer.remove(node.endTag)
3939
})
4040
}
41-
if (!isVoid && !(hasEndTag || isSelfClosing)) {
41+
if (!isVoid && !hasEndTag && !isSelfClosing) {
4242
context.report({
4343
node: node.startTag,
4444
loc: node.startTag.loc,

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,11 @@ tester.run('html-end-tags', rule, {
4949
},
5050
{
5151
filename: 'test.vue',
52-
code: '<template><div><div /></div></template>'
52+
code: '<template><div><self-closing-custom-element/></div></template>'
53+
},
54+
{
55+
filename: 'test.vue',
56+
code: '<template><div><div/></div></template>'
5357
}
5458
],
5559
invalid: [

0 commit comments

Comments
 (0)