Evan You 11 лет назад
Родитель
Сommit
8725ea32d2
3 измененных файлов с 9 добавлено и 13 удалено
  1. 2 3
      src/directives/el.js
  2. 2 3
      src/directives/ref.js
  3. 5 7
      src/instance/init.js

+ 2 - 3
src/directives/el.js

@@ -3,12 +3,11 @@ module.exports = {
   isLiteral: true,
 
   bind: function () {
-    this.owner = this.vm._owner || this.vm
-    this.owner.$$[this.expression] = this.el
+    this.vm._owner.$$[this.expression] = this.el
   },
 
   unbind: function () {
-    this.owner.$$[this.expression] = null
+    this.vm._owner.$$[this.expression] = null
   }
   
 }

+ 2 - 3
src/directives/ref.js

@@ -11,12 +11,11 @@ module.exports = {
       )
       return
     }
-    this.owner = this.vm._owner || this.vm
-    this.owner.$[this.expression] = this.vm
+    this.vm._owner.$[this.expression] = this.vm
   },
 
   unbind: function () {
-    this.owner.$[this.expression] = null
+    this.vm._owner.$[this.expression] = null
   }
   
 }

+ 5 - 7
src/instance/init.js

@@ -53,14 +53,12 @@ exports._init = function (options) {
   // anonymous instances are created by v-if
   // we need to walk along the parent chain to locate the
   // first non-anonymous instance as the owner.
-  var anon = this._isAnonymous = options._anonymous
-  if (anon) {
-    var parent = this.$parent
-    while (parent._isAnonymous) {
-      parent = parent.$parent
-    }
-    this._owner = parent
+  this._isAnonymous = options._anonymous
+  var parent = this.$parent
+  while (parent && parent._isAnonymous) {
+    parent = parent.$parent
   }
+  this._owner = parent
 
   // merge options.
   options = this.$options = mergeOptions(