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