Просмотр исходного кода

fix #716 unwatch causing error during destroy

Evan You 11 лет назад
Родитель
Сommit
515195ad76
1 измененных файлов с 5 добавлено и 1 удалено
  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()
   }
   // teardown all user watchers.
+  var watcher
   for (i in this._userWatchers) {
-    this._userWatchers[i].teardown()
+    watcher = this._userWatchers[i]
+    if (watcher) {
+      watcher.teardown()
+    }
   }
   // remove reference to self on $el
   if (this.$el) {