Browse Source

use simpler syntax guard for v-repeat

Evan You 11 years ago
parent
commit
1c87165342
2 changed files with 6 additions and 20 deletions
  1. 0 3
      src/directive.js
  2. 6 17
      src/directives/repeat.js

+ 0 - 3
src/directive.js

@@ -27,9 +27,6 @@ function Directive (name, el, vm, descriptor, def, host) {
   this.name = name
   this.name = name
   this.el = el
   this.el = el
   this.vm = vm
   this.vm = vm
-  if (def._guard) {
-    def._guard(descriptor)
-  }
   // copy descriptor props
   // copy descriptor props
   this.raw = descriptor.raw
   this.raw = descriptor.raw
   this.expression = descriptor.expression
   this.expression = descriptor.expression

+ 6 - 17
src/directives/repeat.js

@@ -20,6 +20,12 @@ module.exports = {
    */
    */
 
 
   bind: function () {
   bind: function () {
+    // support for item in array syntax
+    var inMatch = this.expression.match(/(.*) in (.*)/)
+    if (inMatch) {
+      this.arg = inMatch[1]
+      this._watcherExp = inMatch[2]
+    }
     // uid as a cache identifier
     // uid as a cache identifier
     this.id = '__v_repeat_' + (++uid)
     this.id = '__v_repeat_' + (++uid)
     // setup anchor nodes
     // setup anchor nodes
@@ -678,24 +684,7 @@ module.exports = {
       this.converted = true
       this.converted = true
       return res
       return res
     }
     }
-  },
-
-  /**
-   * Internal hook to do custom transform on the directive's
-   * descriptor so that it can support special syntax.
-   *
-   * @param {Object} descriptor
-   */
-
-  _guard: function (descriptor) {
-    var exp = descriptor.expression
-    var match = exp.trim().match(/(.*) in (.*)/)
-    if (match) {
-      descriptor.arg = match[1]
-      descriptor.expression = match[2]
-    }
   }
   }
-
 }
 }
 
 
 /**
 /**