Selaa lähdekoodia

support bind-ref

Evan You 10 vuotta sitten
vanhempi
commit
50a46e8a41
2 muutettua tiedostoa jossa 9 lisäystä ja 3 poistoa
  1. 7 1
      src/directive.js
  2. 2 2
      test/unit/specs/directives/for/for_spec.js

+ 7 - 1
src/directive.js

@@ -184,9 +184,15 @@ Directive.prototype._checkStatement = function () {
 
 Directive.prototype.param = function (name) {
   var param = this.el.getAttribute(name)
-  if (param !== null) {
+  if (param != null) {
     this.el.removeAttribute(name)
     param = (this._scope || this.vm).$interpolate(param)
+  } else {
+    param = this.el.getAttribute('bind-' + name)
+    if (param != null) {
+      this.el.removeAttribute('bind-' + name)
+      param = (this._scope || this.vm).$eval(param)
+    }
   }
   return param
 }

+ 2 - 2
test/unit/specs/directives/for/for_spec.js

@@ -664,9 +664,9 @@ if (_.inBrowser) {
       var vm = new Vue({
         el: el,
         template:
-          '<div v-for="item in list" track-by="id" v-ref="outer">' +
+          '<div v-for="item in list" track-by="id" ref="outer">' +
             '{{item.msg}}' +
-            '<div v-for="subItem in item.list" track-by="id" v-ref="inner{{$index}}">' +
+            '<div v-for="subItem in item.list" track-by="id" bind-ref="\'inner\' + $index">' +
               '{{subItem.msg}}' +
             '</div>' +
           '</div>',