Browse Source

update track-by usage

dev
Evan You 9 years ago
parent
commit
68372ea26b
  1. 4
      src/compiler/parser/index.js
  2. 2
      test/unit/features/directives/for.spec.js

4
src/compiler/parser/index.js

@ -216,9 +216,7 @@ function processFor (el) {
el.alias = alias
}
if ((exp = getAndRemoveAttr(el, 'track-by'))) {
el.key = exp === '$index'
? exp
: el.alias + '["' + exp + '"]'
el.key = exp
}
}
}

2
test/unit/features/directives/for.spec.js

@ -295,7 +295,7 @@ describe('Directive v-for', () => {
{ id: 3, msg: 'c' }
]
},
template: '<div><div v-for="item in items" track-by="id">{{ item.msg }}</div></div>'
template: '<div><div v-for="item in items" track-by="item.id">{{ item.msg }}</div></div>'
})
vm.$mount()
expect(vm.$el.textContent).toBe('abc')

Loading…
Cancel
Save