Pārlūkot izejas kodu

fix #716 unwatch causing error during destroy

Evan You 11 gadi atpakaļ
vecāks
revīzija
515195ad76
1 mainītis faili ar 5 papildinājumiem un 1 dzēšanām
  1. 5 1
      src/instance/compile.js

+ 5 - 1
src/instance/compile.js

@@ -143,8 +143,12 @@ exports._destroy = function (remove, deferCleanup) {
     this._directives[i]._teardown()
     this._directives[i]._teardown()
   }
   }
   // teardown all user watchers.
   // teardown all user watchers.
+  var watcher
   for (i in this._userWatchers) {
   for (i in this._userWatchers) {
-    this._userWatchers[i].teardown()
+    watcher = this._userWatchers[i]
+    if (watcher) {
+      watcher.teardown()
+    }
   }
   }
   // remove reference to self on $el
   // remove reference to self on $el
   if (this.$el) {
   if (this.$el) {