Procházet zdrojové kódy

trackby -> track-by

Evan You před 11 roky
rodič
revize
e2fba07a13

+ 3 - 1
src/directives/repeat.js

@@ -42,7 +42,9 @@ module.exports = {
     this.checkRef()
     this.checkComponent()
     // check for trackby param
-    this.idKey = this._checkParam('trackby')
+    this.idKey =
+      this._checkParam('track-by') ||
+      this._checkParam('trackby') // 0.11.0 compat
     // cache for primitive value instances
     this.cache = Object.create(null)
   },

+ 3 - 3
test/unit/specs/directives/repeat_spec.js

@@ -287,10 +287,10 @@ if (_.inBrowser) {
       }
     })
 
-    it('trackby id', function (done) {
+    it('track by id', function (done) {
 
-      assertTrackBy('<div v-repeat="list" trackby="id">{{msg}}</div>', function () {
-        assertTrackBy('<div v-repeat="item:list" trackby="id">{{item.msg}}</div>', done)
+      assertTrackBy('<div v-repeat="list" track-by="id">{{msg}}</div>', function () {
+        assertTrackBy('<div v-repeat="item:list" track-by="id">{{item.msg}}</div>', done)
       })
       
       function assertTrackBy (template, next) {