Skip to content

Commit e9670d5

Browse files
committed
fix watcher accidentally clearing watcherList on teardown (fix #806)
1 parent 7822d71 commit e9670d5

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/watcher.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,10 @@ p.teardown = function () {
222222
// which can improve teardown performance.
223223
if (!this.vm._isBeingDestroyed) {
224224
var list = this.vm._watcherList
225-
list.splice(list.indexOf(this))
225+
var i = list.indexOf(this)
226+
if (i > -1) {
227+
list.splice(i, 1)
228+
}
226229
}
227230
for (var id in this.deps) {
228231
this.deps[id].removeSub(this)

test/unit/specs/directives/model_spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ if (_.inBrowser) {
233233
expect(opts[1].selected).toBe(false)
234234
// should teardown option watcher when unbind
235235
expect(vm._watcherList.length).toBe(2)
236-
vm._directives[0].unbind()
236+
vm._directives[0]._teardown()
237237
expect(vm._watcherList.length).toBe(0)
238238
done()
239239
})

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy