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