|
|
@ -6,7 +6,8 @@ function _classCallCheck(instance, Constructor) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function noop(a, b, c) {} |
|
|
|
function noop(a, b, c) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function isNative(Ctor) { |
|
|
|
function isNative(Ctor) { |
|
|
|
return typeof Ctor === "function" && /native code/.test(Ctor.toString()); |
|
|
|
return typeof Ctor === "function" && /native code/.test(Ctor.toString()); |
|
|
@ -363,7 +364,8 @@ const Watcher = (function () { |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
this.getter = parsePath(expOrFn); |
|
|
|
this.getter = parsePath(expOrFn); |
|
|
|
if (!this.getter) { |
|
|
|
if (!this.getter) { |
|
|
|
this.getter = function () {}; |
|
|
|
this.getter = function() { |
|
|
|
|
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
this.value = this.lazy ? undefined : this.get(); |
|
|
|
this.value = this.lazy ? undefined : this.get(); |
|
|
@ -979,6 +981,7 @@ function watch(model, expOrFn, cb, options) { |
|
|
|
} |
|
|
|
} |
|
|
|
: parsePath(exp); |
|
|
|
: parsePath(exp); |
|
|
|
const v = getter.call(model, model); |
|
|
|
const v = getter.call(model, model); |
|
|
|
|
|
|
|
if (v.__ob__) { |
|
|
|
const _dep = new Dep(); |
|
|
|
const _dep = new Dep(); |
|
|
|
if (isGlobal) { |
|
|
|
if (isGlobal) { |
|
|
|
(v.__ob__._scopeDeps || (v.__ob__._scopeDeps = [])).push( |
|
|
|
(v.__ob__._scopeDeps || (v.__ob__._scopeDeps = [])).push( |
|
|
@ -1009,6 +1012,7 @@ function watch(model, expOrFn, cb, options) { |
|
|
|
v.__ob__._scopeDeps && remove(v.__ob__._scopeDeps, _dep); |
|
|
|
v.__ob__._scopeDeps && remove(v.__ob__._scopeDeps, _dep); |
|
|
|
v.__ob__._deps && remove(v.__ob__._deps, _dep); |
|
|
|
v.__ob__._deps && remove(v.__ob__._deps, _dep); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
@ -1017,6 +1021,11 @@ function watch(model, expOrFn, cb, options) { |
|
|
|
// 先获取到能获取到的对象
|
|
|
|
// 先获取到能获取到的对象
|
|
|
|
const _paths = exp.split("."); |
|
|
|
const _paths = exp.split("."); |
|
|
|
const _currentModel = model[_paths[1]]; |
|
|
|
const _currentModel = model[_paths[1]]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!_currentModel.__ob__) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
exp = `${_paths[1]}.**`; |
|
|
|
exp = `${_paths[1]}.**`; |
|
|
|
// 补全路径
|
|
|
|
// 补全路径
|
|
|
|
let _parent = _currentModel.__ob__.parent, |
|
|
|
let _parent = _currentModel.__ob__.parent, |
|
|
@ -1079,6 +1088,11 @@ function watch(model, expOrFn, cb, options) { |
|
|
|
} |
|
|
|
} |
|
|
|
currentModel = model[paths[_i]]; |
|
|
|
currentModel = model[paths[_i]]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!currentModel.__ob__) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
exp = exp.substr(exp.indexOf("*")); |
|
|
|
exp = exp.substr(exp.indexOf("*")); |
|
|
|
// 补全路径
|
|
|
|
// 补全路径
|
|
|
|
let parent = currentModel.__ob__.parent, |
|
|
|
let parent = currentModel.__ob__.parent, |
|
|
@ -1458,7 +1472,8 @@ const Model = (function () { |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
Model.prototype._init = function _init() {}; |
|
|
|
Model.prototype._init = function _init() { |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
Model.prototype.init = function init() { |
|
|
|
Model.prototype.init = function init() { |
|
|
|
this._init(); |
|
|
|
this._init(); |
|
|
|