diff --git a/packages/fineui/src/fix/fix.js b/packages/fineui/src/fix/fix.js index a28f5e4a8..ddc37b044 100644 --- a/packages/fineui/src/fix/fix.js +++ b/packages/fineui/src/fix/fix.js @@ -7,7 +7,7 @@ const pendingCleanupDeps = []; const cleanupDeps = () => { for (let i = 0; i < pendingCleanupDeps.length; i++) { const dep = pendingCleanupDeps[i]; - dep.subs = dep.subs.filter(s => s); + dep.subs = dep.subs.filter(s => dep.subsSet.has(s.id)); dep._pending = false; } pendingCleanupDeps.length = 0; @@ -23,14 +23,16 @@ class Dep { this.id = uid++; this._pending = false; this.subs = []; + this.subsSet = new Set(); } addSub(sub) { this.subs.push(sub); + this.subsSet.add(sub.id); } removeSub(sub) { - this.subs[this.subs.indexOf(sub)] = null; + this.subsSet.delete(sub.id); if (!this._pending) { this._pending = true; pendingCleanupDeps.push(this); @@ -45,7 +47,7 @@ class Dep { notify(options) { // stabilize the subscriber list first - const subs = this.subs.filter(s => s); + const subs = this.subs.filter(s => this.subsSet.has(s.id)); for (let i = 0, l = subs.length; i < l; i++) { subs[i].update(options); }