浏览代码

fix #716 unwatch causing error during destroy

Evan You 11 年之前
父节点
当前提交
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) {