|
|
@@ -432,77 +432,4 @@ describe('v-if', function () {
|
|
|
done()
|
|
|
})
|
|
|
})
|
|
|
-
|
|
|
- // GitHub issue #3204
|
|
|
- it('update array refs', function (done) {
|
|
|
- var vm = new Vue({
|
|
|
- el: el,
|
|
|
- template: '<foo v-if="!activeItem || $index === activeItem" v-ref:foo :index="$index" v-for="item in items"></foo>',
|
|
|
- data: {
|
|
|
- items: [0, 1, 2],
|
|
|
- activeItem: null
|
|
|
- },
|
|
|
- components: {
|
|
|
- foo: {
|
|
|
- props: ['index'],
|
|
|
- template: '<div>I am foo ({{ index }})<div>'
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
- vm.$refs.foo.forEach(function (ref, index) {
|
|
|
- expect(ref.$el.textContent).toBe('I am foo (' + index + ')')
|
|
|
- expect(ref.index).toBe(index)
|
|
|
- })
|
|
|
- vm.activeItem = 1 // select active item
|
|
|
- nextTick(function () {
|
|
|
- expect(vm.$refs.foo.length).toBe(1)
|
|
|
- expect(vm.$refs.foo[0].index).toBe(1)
|
|
|
- vm.activeItem = null // enable all elements
|
|
|
- nextTick(function () {
|
|
|
- expect(vm.$refs.foo.length).toBe(3)
|
|
|
- done()
|
|
|
- })
|
|
|
- })
|
|
|
- })
|
|
|
-
|
|
|
- it('update object refs', function (done) {
|
|
|
- var vm = new Vue({
|
|
|
- el: el,
|
|
|
- template: '<foo v-if="!activeKey || $key === activeKey" v-ref:foo :key="$key" v-for="item in items"></foo>',
|
|
|
- data: {
|
|
|
- items: {
|
|
|
- a: 1,
|
|
|
- b: 2,
|
|
|
- c: 3
|
|
|
- },
|
|
|
- activeKey: null
|
|
|
- },
|
|
|
- components: {
|
|
|
- foo: {
|
|
|
- props: ['key'],
|
|
|
- template: '<div>I am foo ({{ key }})<div>'
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
- Object.keys(vm.$refs.foo).forEach(function (key) {
|
|
|
- var ref = vm.$refs.foo[key]
|
|
|
- expect(ref.$el.textContent).toBe('I am foo (' + key + ')')
|
|
|
- expect(ref.key).toBe(key)
|
|
|
- })
|
|
|
- vm.activeKey = 'b' // select active item
|
|
|
- nextTick(function () {
|
|
|
- expect(Object.keys(vm.$refs.foo).length).toBe(1)
|
|
|
- expect(vm.$refs.foo['b'].key).toBe('b')
|
|
|
- vm.activeKey = null // enable all elements
|
|
|
- nextTick(function () {
|
|
|
- expect(Object.keys(vm.$refs.foo).length).toBe(3)
|
|
|
- Object.keys(vm.$refs.foo).forEach(function (key) {
|
|
|
- var ref = vm.$refs.foo[key]
|
|
|
- expect(ref.$el.textContent).toBe('I am foo (' + key + ')')
|
|
|
- expect(ref.key).toBe(key)
|
|
|
- })
|
|
|
- done()
|
|
|
- })
|
|
|
- })
|
|
|
- })
|
|
|
})
|