Migration guide section on key attribute changes #481
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of Problem
This is my attempt to fix #379 (a couple of undocumented breaking changes in Vue 3 related to the
key
attribute).Proposed Solution
I think this is technically two separate breaking changes:
key
s onv-if
branches, then each branch must use a uniquekey
.<template v-for>
key
should be placed on the<template>
tag (rather than on its children).However, I think it's probably best to keep them on the same page because they're related and often appear at the same time. For example, they appear together in this relatively common situation:
Additional Information
In my opinion,
key
s are one of the more confusing parts of Vue. That's why I included a "Background" section near the top that explains what thekey
attribute is. I'm not really sure whether this section should be there or not, so I'm totally fine with removing the "Background" if people think it's unnecessary.