fix(compiler-core): v-if key error should only be checking same key on different branches

This commit is contained in:
Evan You
2020-08-04 12:01:07 -04:00
parent c3f8c780e7
commit de0c8a7e3e
5 changed files with 74 additions and 15 deletions

View File

@@ -63,7 +63,7 @@ export const enum ErrorCodes {
// transform errors
X_V_IF_NO_EXPRESSION,
X_V_IF_KEY,
X_V_IF_SAME_KEY,
X_V_ELSE_NO_ADJACENT_IF,
X_V_FOR_NO_EXPRESSION,
X_V_FOR_MALFORMED_EXPRESSION,
@@ -136,10 +136,7 @@ export const errorMessages: { [code: number]: string } = {
// transform errors
[ErrorCodes.X_V_IF_NO_EXPRESSION]: `v-if/v-else-if is missing expression.`,
[ErrorCodes.X_V_IF_KEY]:
`v-if branches must use compiler generated keys. ` +
`In many cases, you can simply remove this key. ` +
`If this tag is inside of a <template v-for="...">, then you can move the key up to the parent <template>.`,
[ErrorCodes.X_V_IF_SAME_KEY]: `v-if/else branches must use unique keys.`,
[ErrorCodes.X_V_ELSE_NO_ADJACENT_IF]: `v-else/v-else-if has no adjacent v-if.`,
[ErrorCodes.X_V_FOR_NO_EXPRESSION]: `v-for is missing expression.`,
[ErrorCodes.X_V_FOR_MALFORMED_EXPRESSION]: `v-for has invalid expression.`,