refactor(reactivity): immediate return (#301)

This commit is contained in:
Tidyzq 2019-10-16 13:58:11 +08:00 committed by Evan You
parent 29811d1fe8
commit a72652f6e6

View File

@ -128,29 +128,30 @@ export function track(
return return
} }
const effect = activeReactiveEffectStack[activeReactiveEffectStack.length - 1] const effect = activeReactiveEffectStack[activeReactiveEffectStack.length - 1]
if (effect) { if (!effect) {
if (type === OperationTypes.ITERATE) { return
key = ITERATE_KEY }
} if (type === OperationTypes.ITERATE) {
let depsMap = targetMap.get(target) key = ITERATE_KEY
if (depsMap === void 0) { }
targetMap.set(target, (depsMap = new Map())) let depsMap = targetMap.get(target)
} if (depsMap === void 0) {
let dep = depsMap.get(key!) targetMap.set(target, (depsMap = new Map()))
if (dep === void 0) { }
depsMap.set(key!, (dep = new Set())) let dep = depsMap.get(key!)
} if (dep === void 0) {
if (!dep.has(effect)) { depsMap.set(key!, (dep = new Set()))
dep.add(effect) }
effect.deps.push(dep) if (!dep.has(effect)) {
if (__DEV__ && effect.onTrack) { dep.add(effect)
effect.onTrack({ effect.deps.push(dep)
effect, if (__DEV__ && effect.onTrack) {
target, effect.onTrack({
type, effect,
key target,
}) type,
} key
})
} }
} }
} }