* Set a property on an object. Adds the new property and * triggers change notification if the property doesn't * already exist.
(target, key, val)
| 880 | * already exist. |
| 881 | */ |
| 882 | function set (target, key, val) { |
| 883 | if (Array.isArray(target) && typeof key === 'number') { |
| 884 | target.length = Math.max(target.length, key); |
| 885 | target.splice(key, 1, val); |
| 886 | return val |
| 887 | } |
| 888 | if (hasOwn(target, key)) { |
| 889 | target[key] = val; |
| 890 | return val |
| 891 | } |
| 892 | var ob = (target ).__ob__; |
| 893 | if (target._isVue || (ob && ob.vmCount)) { |
| 894 | "development" !== 'production' && warn( |
| 895 | 'Avoid adding reactive properties to a Vue instance or its root $data ' + |
| 896 | 'at runtime - declare it upfront in the data option.' |
| 897 | ); |
| 898 | return val |
| 899 | } |
| 900 | if (!ob) { |
| 901 | target[key] = val; |
| 902 | return val |
| 903 | } |
| 904 | defineReactive$$1(ob.value, key, val); |
| 905 | ob.dep.notify(); |
| 906 | return val |
| 907 | } |
| 908 | |
| 909 | /** |
| 910 | * Delete a property and trigger change if necessary. |
no test coverage detected