Skip to content

Commit bcb5e51

Browse files
committed
stablize subscribers in dep notify loop
1 parent 441baf3 commit bcb5e51

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/observer/dep.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
var uid = 0
2+
var _ = require('../util')
23

34
/**
45
* A dep is an observable that can have multiple
@@ -42,7 +43,9 @@ p.removeSub = function (sub) {
4243
*/
4344

4445
p.notify = function () {
45-
for (var i = 0, subs = this.subs; i < subs.length; i++) {
46+
// stablize the subscriber list first
47+
var subs = _.toArray(this.subs)
48+
for (var i = 0, l = subs.length; i < l; i++) {
4649
subs[i].update()
4750
}
4851
}

0 commit comments

Comments
 (0)