-
-
Notifications
You must be signed in to change notification settings - Fork 679
Overcritical vue/valid-template-root rule? #971
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
Comments
Thank you for this issue. Your template will fail to compile on Vue Template Explorer. I think this rule is working correctly. |
Thanks for looking into this 😊 This is interesting. I tested it within our build process, which uses the official const vueTemplateCompiler = require('vue-template-compiler');
const { render, staticRenderFns } = vueTemplateCompiler.compile(`
<template v-if="isValid">
True
</template>
<template v-else>
False
</template>
`);
console.log(render);
console.log(staticRenderFns); Output:
After your comment, I further investigated this behaviour and saw that
After investigating the compiler's source code, I saw that the warning will always be generated if either How about an option for |
This should fix all medium-and-above severity security issues reported by npm audit. The only remaining issue that cannot be fixed by running `npm upgrade` or `npm audit fix` will be fixed in a follow-up commit. The rule to enforce a single root in vue templates seems to be a bit overzealous. This has already been reported upstream in vuejs/eslint-plugin-vue#971 and was also discussed in vuejs/eslint-plugin-vue#884 and vuejs/eslint-plugin-vue#986 without obvious solution that would be applicable here. Solved by adding a not strictly necessary wrapping span. Change-Id: I3153c0f45ce53704ef2c02d7e2e2e4f6d67e3fc7
* Update Wikibase from branch 'master' to e7ada5fde5f187fef50badd632676363f322691f - Merge "bridge: Upgrade dependencies" - bridge: Upgrade dependencies This should fix all medium-and-above severity security issues reported by npm audit. The only remaining issue that cannot be fixed by running `npm upgrade` or `npm audit fix` will be fixed in a follow-up commit. The rule to enforce a single root in vue templates seems to be a bit overzealous. This has already been reported upstream in vuejs/eslint-plugin-vue#971 and was also discussed in vuejs/eslint-plugin-vue#884 and vuejs/eslint-plugin-vue#986 without obvious solution that would be applicable here. Solved by adding a not strictly necessary wrapping span. Change-Id: I3153c0f45ce53704ef2c02d7e2e2e4f6d67e3fc7
Why has this been closed? I do not think it has been fixed? |
@sebiniemann I'm using the new Vue 3 "Vite" with |
Sorry @mitar I must have missed the notification. After further discussions over another channel, I closed this issue. While VueJS technically supports if/else templates as root, this (unfortunately) does not seems to be an official feature. @716green I have not yet read up completely on the new VueJS 3 features. Is this now officially supported in the current VueJS 3 alpha (and probably after that)? Would be great. |
How is this not an official feature in Vue (before 3)? It was asked through an issue vuejs/vue#3878 and support for it explicitly added vuejs/vue#3887 already in 2016. |
This is separate from vuejs/vue#4128, which I agree it should not be supported. But |
Thanks for the clarification @mitar The main difference is that our use case only uses templates for such manipulations (mainly due to a migration from other frameworks that use non-HTML expressions for loops and if statements). And since it can be further rewritten to avoid As stated last year, after the feedback from @ota-meshi in this thread, the problems lies not within the if/else part, but with the Technically, everything works fine, especially if there is only one element behind it, as the warning says:
However, |
I see. I in fact missed that this issue is about
So this is just invalid, no? |
Hi. Sorry for the late reply. The The aims of This rule will report an error as If you have any other issues, please open a new issue. |
Awesome, if this works. |
Uh oh!
There was an error while loading. Please reload this page.
Tell us about your environment
Please show your full configuration:
What did you do?
https://mysticatea.github.io/vue-eslint-demo/#eJxVjsEKwjAQRH8l7Lmh4DGIZ+8KXryEZiqBmA2bpFBL/91YEepl4e3bYXahgR3I0LHgmYItON2jUv+k1BkhsLqxBLfpfud3QB1JDchkFpoq+sh64DjW7ONDT3pkadOPZA7d5icbvNO/uBbm0tzakY8OsVz8C9vtF69z+nyakx3QmpKVDGkL5CQArW/g3EXT
My actual use case is something like
where we always use
<template>
in conjunction withv-for
,v-if
, ...https://mysticatea.github.io/vue-eslint-demo/#eJx1kM9KxDAQxl9lmJNCQ8FjXT36Ai576iU0EwnEJEwmxd3Sdzdpu4KIp3y/mW/+ZcEpGsIBT0KfyWuh1zEA/BDMytmXEV2+aO/MiFsa4MyFNmP/bx35TIf7TVf9x/4LKuaJXZKq6StFFjBkdfECS6s0WvTD464BmKRwuBPAsd4Atk3q9vD63N61UlOn/uiPHXLxlHFYcC7Uh6imGGzJLnyoWdnIqh2Nw1O35efWWd1XVRyj1NzaoQuGgry7G23eHc/X1L4zJz1RnZQ0Z+IaoJyYCNdvtNp8aA==
What did you expect to happen?
No error, as Vue compiles without problem.
What actually happened?
The text was updated successfully, but these errors were encountered: