File tree 1 file changed +9
-4
lines changed
1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -196,10 +196,15 @@ export function defineReactive (
196
196
* already exist.
197
197
*/
198
198
export function set ( target : Array < any > | Object , key : any , val : any ) : any {
199
- if ( process . env . NODE_ENV !== 'production' &&
200
- ( isUndef ( target ) || isPrimitive ( target ) )
201
- ) {
202
- warn ( `Cannot set reactive property on undefined, null, or primitive value: ${ ( target : any ) } ` )
199
+ if ( process . env . NODE_ENV !== 'production' ) {
200
+ if ( isUndef ( target ) || isPrimitive ( target ) ) {
201
+ warn ( `Cannot set reactive property on undefined, null, or primitive value: ${ ( target : any ) } ` )
202
+ }
203
+ if ( Object . getOwnPropertyDescriptor ( target , key ) &&
204
+ ( typeof ( Object . getOwnPropertyDescriptor ( target , key ) . get ) === 'undefined' ) &&
205
+ ! Array . isArray ( target ) ) {
206
+ warn ( `Cannot enable reactivity on a property that is already defined: ${ ( key : any ) } ` )
207
+ }
203
208
}
204
209
if ( Array . isArray ( target ) && isValidArrayIndex ( key ) ) {
205
210
target . length = Math . max ( target . length , key )
You can’t perform that action at this time.
0 commit comments