question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Self closing elements break v-if rules

See original GitHub issue

Self-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:closed
  • Created 6 years ago
  • Comments:13 (13 by maintainers)

github_iconTop GitHub Comments

2reactions
kazuponcommented, Jun 18, 2017

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

2reactions
yyx990803commented, Jun 17, 2017

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found