Self closing elements break v-if rules
See original GitHub issueSelf-closing elements break the following rules:
- vue/no-invalid-template-root
- vue/no-invalid-v-else-if
- vue/no-invalid-v-else
Expected
This should not be reported:
<template>
<c1 v-if="1" />
<c2 v-else-if="1" />
<c3 v-else />
</template>
Happening
This works:
<template>
<c1 v-if="1"></c1>
<c2 v-else-if="1"></c2>
<c3 v-else></c3>
</template>
This doesn’t:
<template>
<c1 v-if="1" />
<c2 v-else-if="1" />
<c3 v-else />
</template>
Here are the report messages:
26:3 error The template root requires the next element which has 'v-else' directives if it has 'v-if' directives vue/no-invalid-template-root
27:7 error 'v-else-if' directives require being preceded by the element which has a 'v-if' or 'v-else-if' directive vue/no-invalid-v-else-if
28:7 error 'v-else' directives require being preceded by the element which has a 'v-if' or 'v-else' directive vue/no-invalid-v-else
Issue Analytics
- State:
- Created 6 years ago
- Comments:13 (13 by maintainers)
Top Results From Across the Web
What are Self Closing Tags in HTML? - Scaler Topics
Self -closing tags in HTML only have attributes and do not contain any content, and they also cannot have any children.
Read more >Why are some tags self-closing but others are not? - HTML FAQ
The important distinction between self-closing tags and all other tags is that self-closing tags represent void elements.
Read more >Remove all references to "self-closing" void elements in core
Remove self-closing void tags from output of filter module without breaking its current behavior. Filters should not forcibly remove the ...
Read more >Self Closing Tags in HTML (With Examples) - Tutorials Tonight
A self closing tags in HTML are the type of HTML tags that need not to be closed manually by its closing tag,...
Read more >HTML Singleton Tags With No Closing Tag - ThoughtCo
There can be no more than one of these per document and it must be in the head of the page. <br>: A...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Though it may be related to these, we might as well try to design plugin architecture of
vue-template-compiler
.https://github.com/vuejs/vue/issues/5703 https://github.com/vuejs/vue/pull/5857
@mysticatea have you thought of building the new parser on top of Vue’s parser? I can expose the parse method in
vue-template-compiler
and you should be able to pretty easily transform the AST to the format suitable for ESLint. It would also be more accurate and kept up-to-date with Vue core updates.