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