fix(compiler-core): avoid override user keys when injecting branch key (#630)
This commit is contained in:
@@ -253,7 +253,18 @@ export function injectProp(
|
||||
}
|
||||
propsWithInjection = props
|
||||
} else if (props.type === NodeTypes.JS_OBJECT_EXPRESSION) {
|
||||
props.properties.unshift(prop)
|
||||
let alreadyExists = false
|
||||
// check existing key to avoid overriding user provided keys
|
||||
if (prop.key.type === NodeTypes.SIMPLE_EXPRESSION) {
|
||||
const propKeyName = prop.key.content
|
||||
alreadyExists = props.properties.some(p => (
|
||||
p.key.type === NodeTypes.SIMPLE_EXPRESSION &&
|
||||
p.key.content === propKeyName
|
||||
))
|
||||
}
|
||||
if (!alreadyExists) {
|
||||
props.properties.unshift(prop)
|
||||
}
|
||||
propsWithInjection = props
|
||||
} else {
|
||||
// single v-bind with expression, return a merged replacement
|
||||
|
||||
Reference in New Issue
Block a user