|
|
@ -788,53 +788,6 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons |
|
|
|
function defineReactive(obj, observer, shallow) { |
|
|
|
function defineReactive(obj, observer, shallow) { |
|
|
|
var props = {}; |
|
|
|
var props = {}; |
|
|
|
var model = void 0; |
|
|
|
var model = void 0; |
|
|
|
// if (typeof Proxy === 'function') {
|
|
|
|
|
|
|
|
// const deps = {}, childObs = {}, cache = {}
|
|
|
|
|
|
|
|
// _.each(obj, function (val, key) {
|
|
|
|
|
|
|
|
// if (key in $$skipArray) {
|
|
|
|
|
|
|
|
// return
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// cache[key] = val
|
|
|
|
|
|
|
|
// const dep = deps[key] = (observer && observer['__dep' + key]) || new Dep()
|
|
|
|
|
|
|
|
// observer && (observer['__dep' + key] = dep)
|
|
|
|
|
|
|
|
// childObs[key] = !shallow && observe(val, observer, key)
|
|
|
|
|
|
|
|
// })
|
|
|
|
|
|
|
|
// return model = new Proxy(props, {
|
|
|
|
|
|
|
|
// has: function (target, key) {
|
|
|
|
|
|
|
|
// return key in obj;
|
|
|
|
|
|
|
|
// },
|
|
|
|
|
|
|
|
// get: function (target, key) {
|
|
|
|
|
|
|
|
// if (key in $$skipArray) {
|
|
|
|
|
|
|
|
// return target[key]
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// const value = cache[key]
|
|
|
|
|
|
|
|
// if (Dep.target) {
|
|
|
|
|
|
|
|
// deps[key].depend()
|
|
|
|
|
|
|
|
// if (childObs[key]) {
|
|
|
|
|
|
|
|
// childObs[key].dep.depend()
|
|
|
|
|
|
|
|
// if (_.isArray(value)) {
|
|
|
|
|
|
|
|
// dependArray(value)
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// return value
|
|
|
|
|
|
|
|
// },
|
|
|
|
|
|
|
|
// set: function (target, key, newVal) {
|
|
|
|
|
|
|
|
// if (key in $$skipArray) {
|
|
|
|
|
|
|
|
// return target[key] = newVal
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// const value = cache[key], dep = deps[key]
|
|
|
|
|
|
|
|
// if (newVal === value || (newVal !== newVal && value !== value)) {
|
|
|
|
|
|
|
|
// return newVal
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// cache[key] = newVal
|
|
|
|
|
|
|
|
// childObs[key] = !shallow && observe(newVal, observer, key)
|
|
|
|
|
|
|
|
// obj[key] = childObs[key] ? childObs[key].model : newVal
|
|
|
|
|
|
|
|
// notify(model, key, dep)
|
|
|
|
|
|
|
|
// return obj[key]
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// })
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
_.each(obj, function (val, key) { |
|
|
|
_.each(obj, function (val, key) { |
|
|
|
if (key in $$skipArray) { |
|
|
|
if (key in $$skipArray) { |
|
|
|
return; |
|
|
|
return; |
|
|
@ -878,6 +831,50 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons |
|
|
|
return model = createViewModel$1(obj, props); |
|
|
|
return model = createViewModel$1(obj, props); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function defineReactiveProperty(obj, key, val, shallow) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var dep = new Dep(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var configurable = isConfigurable(obj, key); |
|
|
|
|
|
|
|
if (!configurable) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (arguments.length === 2) { |
|
|
|
|
|
|
|
val = obj[key]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var childOb = !shallow && observe(val); |
|
|
|
|
|
|
|
Object.defineProperty(obj, key, { |
|
|
|
|
|
|
|
enumerable: true, |
|
|
|
|
|
|
|
configurable: true, |
|
|
|
|
|
|
|
get: function reactiveGetter() { |
|
|
|
|
|
|
|
var value = childOb ? childOb.model : val; |
|
|
|
|
|
|
|
if (Dep.target) { |
|
|
|
|
|
|
|
dep.depend(); |
|
|
|
|
|
|
|
if (childOb) { |
|
|
|
|
|
|
|
childOb.dep.depend(); |
|
|
|
|
|
|
|
if (_.isArray(value)) { |
|
|
|
|
|
|
|
dependArray(value); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return value; |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
set: function reactiveSetter(newVal) { |
|
|
|
|
|
|
|
var value = childOb ? childOb.model : val; |
|
|
|
|
|
|
|
if (newVal === value || newVal !== newVal && value !== value) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
childOb = configurable && !shallow && observe(newVal); |
|
|
|
|
|
|
|
val = newVal; |
|
|
|
|
|
|
|
obj[key] = childOb ? childOb.model : newVal; |
|
|
|
|
|
|
|
dep.notify(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Set a property on an object. Adds the new property and |
|
|
|
* Set a property on an object. Adds the new property and |
|
|
|
* triggers change notification if the property doesn't |
|
|
|
* triggers change notification if the property doesn't |
|
|
@ -1522,6 +1519,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons |
|
|
|
exports.observe = observe; |
|
|
|
exports.observe = observe; |
|
|
|
exports.notify = notify; |
|
|
|
exports.notify = notify; |
|
|
|
exports.defineReactive = defineReactive; |
|
|
|
exports.defineReactive = defineReactive; |
|
|
|
|
|
|
|
exports.defineReactiveProperty = defineReactiveProperty; |
|
|
|
exports.set = set; |
|
|
|
exports.set = set; |
|
|
|
exports.freeze = freeze; |
|
|
|
exports.freeze = freeze; |
|
|
|
exports.del = del; |
|
|
|
exports.del = del; |
|
|
|