-
-
Notifications
You must be signed in to change notification settings - Fork 680
fix #255: Add new rule require-v-if-else-key #1845
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this rule. I have a few suggestions.
Co-authored-by: Flo Edelmann <florian-edelmann@online.de>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please run npm run update
to update the docs and fix all lint issues.
Other than that, this looks good to me. Thanks!
</template> | ||
</div> | ||
</template> | ||
` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this valid? I think this should be reported.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I must have misinterpreted your comment:
Note that vue2 does not allow you to place a key in .
If no keys are allowed, mustn't we allow templates without keys?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Vue2 need to put the key on the actual element, not the <template>
.
e.g.
<template v-if="foo">
<div key="a" />
</template>
<template v-else>
<div key="b" />
</template>
<template v-if="foo">
<div key="a" />
<div key="b" />
</template>
<template v-else>
<div key="c" />
<div key="d" />
</template>
However, with Vue3 you can do the following:
<template v-if="foo" key="a">
<div />
</template>
<template v-else key="b">
<div />
</template>
<template v-if="foo" key="a">
<div />
<div />
</template>
<template v-else key="b">
<div />
<div />
</template>
Heya, things have gotten pretty busy for me, and I don't think I'll have time to clean this one up in the near future. I'm going to close this one for now. |
This one's probably a smidge later than it could have been -- I can't find it in the style guide anymore -- but better late than never?