|
|
@@ -194,6 +194,12 @@ export function defineReactive (
|
|
|
* already exist.
|
|
|
*/
|
|
|
export function set (target: Array<any> | Object, key: any, val: any): any {
|
|
|
+ if (process.env.NODE_ENV !== 'production' &&
|
|
|
+ !Array.isArray(target) &&
|
|
|
+ !isObject(target)
|
|
|
+ ) {
|
|
|
+ warn(`Cannot set reactive property on non-object/array value: ${target}`)
|
|
|
+ }
|
|
|
if (Array.isArray(target) && isValidArrayIndex(key)) {
|
|
|
target.length = Math.max(target.length, key)
|
|
|
target.splice(key, 1, val)
|
|
|
@@ -224,6 +230,12 @@ export function set (target: Array<any> | Object, key: any, val: any): any {
|
|
|
* Delete a property and trigger change if necessary.
|
|
|
*/
|
|
|
export function del (target: Array<any> | Object, key: any) {
|
|
|
+ if (process.env.NODE_ENV !== 'production' &&
|
|
|
+ !Array.isArray(target) &&
|
|
|
+ !isObject(target)
|
|
|
+ ) {
|
|
|
+ warn(`Cannot delete reactive property on non-object/array value: ${target}`)
|
|
|
+ }
|
|
|
if (Array.isArray(target) && isValidArrayIndex(key)) {
|
|
|
target.splice(key, 1)
|
|
|
return
|