refactor(reactivity): simplify if condition (#1002)
This commit is contained in:
parent
6390093691
commit
fa40d1ef3a
@ -141,11 +141,11 @@ export function track(target: object, type: TrackOpTypes, key: unknown) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
let depsMap = targetMap.get(target)
|
let depsMap = targetMap.get(target)
|
||||||
if (depsMap === void 0) {
|
if (!depsMap) {
|
||||||
targetMap.set(target, (depsMap = new Map()))
|
targetMap.set(target, (depsMap = new Map()))
|
||||||
}
|
}
|
||||||
let dep = depsMap.get(key)
|
let dep = depsMap.get(key)
|
||||||
if (dep === void 0) {
|
if (!dep) {
|
||||||
depsMap.set(key, (dep = new Set()))
|
depsMap.set(key, (dep = new Set()))
|
||||||
}
|
}
|
||||||
if (!dep.has(activeEffect)) {
|
if (!dep.has(activeEffect)) {
|
||||||
@ -171,7 +171,7 @@ export function trigger(
|
|||||||
oldTarget?: Map<unknown, unknown> | Set<unknown>
|
oldTarget?: Map<unknown, unknown> | Set<unknown>
|
||||||
) {
|
) {
|
||||||
const depsMap = targetMap.get(target)
|
const depsMap = targetMap.get(target)
|
||||||
if (depsMap === void 0) {
|
if (!depsMap) {
|
||||||
// never been tracked
|
// never been tracked
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -179,7 +179,7 @@ export function trigger(
|
|||||||
const effects = new Set<ReactiveEffect>()
|
const effects = new Set<ReactiveEffect>()
|
||||||
const computedRunners = new Set<ReactiveEffect>()
|
const computedRunners = new Set<ReactiveEffect>()
|
||||||
const add = (effectsToAdd: Set<ReactiveEffect> | undefined) => {
|
const add = (effectsToAdd: Set<ReactiveEffect> | undefined) => {
|
||||||
if (effectsToAdd !== void 0) {
|
if (effectsToAdd) {
|
||||||
effectsToAdd.forEach(effect => {
|
effectsToAdd.forEach(effect => {
|
||||||
if (effect !== activeEffect || !shouldTrack) {
|
if (effect !== activeEffect || !shouldTrack) {
|
||||||
if (effect.options.computed) {
|
if (effect.options.computed) {
|
||||||
@ -238,7 +238,7 @@ export function trigger(
|
|||||||
oldTarget
|
oldTarget
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if (effect.options.scheduler !== void 0) {
|
if (effect.options.scheduler) {
|
||||||
effect.options.scheduler(effect)
|
effect.options.scheduler(effect)
|
||||||
} else {
|
} else {
|
||||||
effect()
|
effect()
|
||||||
|
Loading…
Reference in New Issue
Block a user