+8
-8
lines changedFilter options
+8
-8
lines changed Original file line number Diff line number Diff line change
@@ -10,6 +10,8 @@ import {
10
10
hasProto,
11
11
isObject,
12
12
isPlainObject,
13
+
isPrimitive,
14
+
isUndef,
13
15
isValidArrayIndex,
14
16
isServerRendering
15
17
} from '../util/index'
@@ -195,10 +197,9 @@ export function defineReactive (
195
197
*/
196
198
export function set (target: Array<any> | Object, key: any, val: any): any {
197
199
if (process.env.NODE_ENV !== 'production' &&
198
-
!Array.isArray(target) &&
199
-
!isObject(target)
200
+
(isUndef(target) || isPrimitive(target))
200
201
) {
201
-
warn(`Cannot set reactive property on non-object/array value: ${target}`)
202
+
warn(`Cannot set reactive property on undefined, null, or primitive value: ${(target: any)}`)
202
203
}
203
204
if (Array.isArray(target) && isValidArrayIndex(key)) {
204
205
target.length = Math.max(target.length, key)
@@ -231,10 +232,9 @@ export function set (target: Array<any> | Object, key: any, val: any): any {
231
232
*/
232
233
export function del (target: Array<any> | Object, key: any) {
233
234
if (process.env.NODE_ENV !== 'production' &&
234
-
!Array.isArray(target) &&
235
-
!isObject(target)
235
+
(isUndef(target) || isPrimitive(target))
236
236
) {
237
-
warn(`Cannot delete reactive property on non-object/array value: ${target}`)
237
+
warn(`Cannot delete reactive property on undefined, null, or primitive value: ${(target: any)}`)
238
238
}
239
239
if (Array.isArray(target) && isValidArrayIndex(key)) {
240
240
target.splice(key, 1)
Original file line number Diff line number Diff line change
@@ -360,12 +360,12 @@ describe('Observer', () => {
360
360
try {
361
361
setProp(null, 'foo', 1)
362
362
} catch (e) {}
363
-
expect(`Cannot set reactive property on non-object/array value`).toHaveBeenWarned()
363
+
expect(`Cannot set reactive property on undefined, null, or primitive value`).toHaveBeenWarned()
364
364
365
365
try {
366
366
delProp(null, 'foo')
367
367
} catch (e) {}
368
-
expect(`Cannot delete reactive property on non-object/array value`).toHaveBeenWarned()
368
+
expect(`Cannot delete reactive property on undefined, null, or primitive value`).toHaveBeenWarned()
369
369
})
370
370
371
371
it('should lazy invoke existing getters', () => {
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4