|
|
|
@ -244,7 +244,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
var result = original.apply(this, args); |
|
|
|
|
ob.dep.notify(); |
|
|
|
|
notify(ob.parent, ob.parentKey, ob.dep); |
|
|
|
|
return result; |
|
|
|
|
}; |
|
|
|
|
}); |
|
|
|
@ -452,16 +452,17 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
|
|
return ob; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function notify(model, key, dep) { |
|
|
|
|
function notify(observer, key, dep) { |
|
|
|
|
dep.notify(); |
|
|
|
|
if (observer) { |
|
|
|
|
//触发a.*绑定的依赖
|
|
|
|
|
_.each(model.__ob__._deps, function (dep) { |
|
|
|
|
_.each(observer._deps, function (dep) { |
|
|
|
|
dep.notify(); |
|
|
|
|
}); |
|
|
|
|
//触发a.**绑定的依赖
|
|
|
|
|
var parent = model.__ob__, |
|
|
|
|
root = model.__ob__, |
|
|
|
|
route = key; |
|
|
|
|
var parent = observer, |
|
|
|
|
root = observer, |
|
|
|
|
route = key || ""; |
|
|
|
|
while (parent) { |
|
|
|
|
_.each(parent._scopeDeps, function (dep) { |
|
|
|
|
dep.notify(); |
|
|
|
@ -479,6 +480,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function defineReactive(obj, observer, shallow) { |
|
|
|
|
var props = {}; |
|
|
|
@ -561,7 +563,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
|
|
val = newVal; |
|
|
|
|
childOb = !shallow && observe(newVal, observer, key); |
|
|
|
|
obj[key] = childOb ? childOb.model : newVal; |
|
|
|
|
notify(model, key, dep); |
|
|
|
|
notify(model.__ob__, key, dep); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
}); |
|
|
|
@ -590,7 +592,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
|
|
} |
|
|
|
|
ob.value[key] = val; |
|
|
|
|
target = defineReactive(ob.value, ob); |
|
|
|
|
ob.dep.notify(); |
|
|
|
|
notify(ob, key, ob.dep); |
|
|
|
|
return target; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -612,7 +614,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
|
|
} |
|
|
|
|
delete ob.value[key]; |
|
|
|
|
target = defineReactive(ob.value, ob); |
|
|
|
|
ob.dep.notify(); |
|
|
|
|
notify(ob, key, ob.dep); |
|
|
|
|
return target; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -956,7 +958,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
//a.**或a.*形式
|
|
|
|
|
if (/^[1-9a-zA-Z.]+(\*\*$|\*$)/.test(exp)) { |
|
|
|
|
if (/^[1-9a-zA-Z.]+(\*\*$|\*$)/.test(exp) || exp === "**") { |
|
|
|
|
var isGlobal = /\*\*$/.test(exp); |
|
|
|
|
if (isGlobal) { |
|
|
|
|
//a.**的形式
|
|
|
|
@ -965,7 +967,9 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
|
|
//a.*的形式
|
|
|
|
|
exp = exp.replace(".*", ""); |
|
|
|
|
} |
|
|
|
|
var getter = parsePath(exp); |
|
|
|
|
var getter = exp === "**" ? function (m) { |
|
|
|
|
return m; |
|
|
|
|
} : parsePath(exp); |
|
|
|
|
var v = getter.call(model, model); |
|
|
|
|
var dep = new Dep(); |
|
|
|
|
if (isGlobal) { |
|
|
|
@ -1319,6 +1323,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
|
|
exports.observerState = observerState; |
|
|
|
|
exports.Observer = Observer; |
|
|
|
|
exports.observe = observe; |
|
|
|
|
exports.notify = notify; |
|
|
|
|
exports.defineReactive = defineReactive; |
|
|
|
|
exports.set = set; |
|
|
|
|
exports.del = del; |
|
|
|
|