Parcourir la source

trackby -> track-by

Evan You il y a 11 ans
Parent
commit
e2fba07a13
2 fichiers modifiés avec 6 ajouts et 4 suppressions
  1. 3 1
      src/directives/repeat.js
  2. 3 3
      test/unit/specs/directives/repeat_spec.js

+ 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) {