Skip to content

Commit 9609d1e

Browse files
committedDec 22, 2017
refactor: use forEach loop in setComputed
1 parent 2bf5489 commit 9609d1e

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed
 

‎src/wrappers/wrapper.js

+3-7
Original file line numberDiff line numberDiff line change
@@ -418,20 +418,16 @@ export default class Wrapper implements BaseWrapper {
418418
} else {
419419
let isStore = false
420420
// $FlowIgnore : Problem with possibly null this.vm
421-
const max = this.vm._watchers.length
422-
for (let i = 0; i < max; i++) {
423-
// $FlowIgnore : Problem with possibly null this.vm
424-
const watcher = this.vm._watchers[i]
425-
// $FlowIgnore : Problem with possibly null this.vm
421+
this.vm._watchers.forEach(watcher => {
426422
if (watcher.getter.vuex && key in watcher.vm.$options.store.getters) {
427423
watcher.vm.$options.store.getters = {
428424
...watcher.vm.$options.store.getters
429425
}
430426
Object.defineProperty(watcher.vm.$options.store.getters, key, { get: function () { return computed[key] } })
431427
isStore = true
432-
break
433428
}
434-
}
429+
})
430+
435431
// $FlowIgnore : Problem with possibly null this.vm
436432
if (!isStore && !this.vm._watchers.some(w => w.getter.name === key)) {
437433
throwError(`wrapper.setComputed() was passed a value that does not exist as a computed property on the Vue instance. Property ${key} does not exist on the Vue instance`)

0 commit comments

Comments
 (0)
Please sign in to comment.