Skip to content

Commit fa40d1e

Browse files
authored
refactor(reactivity): simplify if condition (#1002)
1 parent 6390093 commit fa40d1e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

packages/reactivity/src/effect.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,11 @@ export function track(target: object, type: TrackOpTypes, key: unknown) {
141141
return
142142
}
143143
let depsMap = targetMap.get(target)
144-
if (depsMap === void 0) {
144+
if (!depsMap) {
145145
targetMap.set(target, (depsMap = new Map()))
146146
}
147147
let dep = depsMap.get(key)
148-
if (dep === void 0) {
148+
if (!dep) {
149149
depsMap.set(key, (dep = new Set()))
150150
}
151151
if (!dep.has(activeEffect)) {
@@ -171,15 +171,15 @@ export function trigger(
171171
oldTarget?: Map<unknown, unknown> | Set<unknown>
172172
) {
173173
const depsMap = targetMap.get(target)
174-
if (depsMap === void 0) {
174+
if (!depsMap) {
175175
// never been tracked
176176
return
177177
}
178178

179179
const effects = new Set<ReactiveEffect>()
180180
const computedRunners = new Set<ReactiveEffect>()
181181
const add = (effectsToAdd: Set<ReactiveEffect> | undefined) => {
182-
if (effectsToAdd !== void 0) {
182+
if (effectsToAdd) {
183183
effectsToAdd.forEach(effect => {
184184
if (effect !== activeEffect || !shouldTrack) {
185185
if (effect.options.computed) {
@@ -238,7 +238,7 @@ export function trigger(
238238
oldTarget
239239
})
240240
}
241-
if (effect.options.scheduler !== void 0) {
241+
if (effect.options.scheduler) {
242242
effect.options.scheduler(effect)
243243
} else {
244244
effect()

0 commit comments

Comments
 (0)