|
| 1 | +import './patch-array' |
1 | 2 | import Dep from './dep'
|
2 |
| -import { arrayMethods } from './array' |
3 | 3 | import {
|
4 | 4 | def,
|
5 | 5 | isArray,
|
6 | 6 | isObject,
|
7 | 7 | isPlainObject,
|
8 |
| - hasProto, |
9 | 8 | hasOwn
|
10 | 9 | } from '../util/index'
|
11 | 10 |
|
12 |
| -const arrayKeys = Object.getOwnPropertyNames(arrayMethods) |
13 |
| - |
14 | 11 | /**
|
15 | 12 | * By default, when a reactive property is set, the new value is
|
16 | 13 | * also converted to become reactive. However in certain cases, e.g.
|
@@ -43,10 +40,6 @@ export function Observer (value) {
|
43 | 40 | this.dep = new Dep()
|
44 | 41 | def(value, '__ob__', this)
|
45 | 42 | if (isArray(value)) {
|
46 |
| - var augment = hasProto |
47 |
| - ? protoAugment |
48 |
| - : copyAugment |
49 |
| - augment(value, arrayMethods, arrayKeys) |
50 | 43 | this.observeArray(value)
|
51 | 44 | } else {
|
52 | 45 | this.walk(value)
|
@@ -118,37 +111,6 @@ Observer.prototype.removeVm = function (vm) {
|
118 | 111 | this.vms.$remove(vm)
|
119 | 112 | }
|
120 | 113 |
|
121 |
| -// helpers |
122 |
| - |
123 |
| -/** |
124 |
| - * Augment an target Object or Array by intercepting |
125 |
| - * the prototype chain using __proto__ |
126 |
| - * |
127 |
| - * @param {Object|Array} target |
128 |
| - * @param {Object} src |
129 |
| - */ |
130 |
| - |
131 |
| -function protoAugment (target, src) { |
132 |
| - /* eslint-disable no-proto */ |
133 |
| - target.__proto__ = src |
134 |
| - /* eslint-enable no-proto */ |
135 |
| -} |
136 |
| - |
137 |
| -/** |
138 |
| - * Augment an target Object or Array by defining |
139 |
| - * hidden properties. |
140 |
| - * |
141 |
| - * @param {Object|Array} target |
142 |
| - * @param {Object} proto |
143 |
| - */ |
144 |
| - |
145 |
| -function copyAugment (target, src, keys) { |
146 |
| - for (var i = 0, l = keys.length; i < l; i++) { |
147 |
| - var key = keys[i] |
148 |
| - def(target, key, src[key]) |
149 |
| - } |
150 |
| -} |
151 |
| - |
152 | 114 | /**
|
153 | 115 | * Attempt to create an observer instance for a value,
|
154 | 116 | * returns the new observer if successfully observed,
|
|
0 commit comments