Skip to content

Commit

Permalink
fix: nextTick await (#414)
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Jun 30, 2020
1 parent 64b16ff commit 85ffede
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/nextTick.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ export const nextTick: NextTick = function nextTick(
this: ThisType<NextTick>,
...args: Parameters<NextTick>
) {
return currentVue?.nextTick.bind(this, args)
return currentVue?.nextTick.apply(this, args)
} as any
23 changes: 23 additions & 0 deletions test/misc.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,27 @@ describe('nextTick', () => {
})
})
})

it('should works with await', async () => {
const vm = new Vue({
template: `<div>{{a}}</div>`,
setup() {
return {
a: ref(1),
}
},
}).$mount()

expect(vm.$el.textContent).toBe('1')
vm.a = 2
expect(vm.$el.textContent).toBe('1')

await nextTick()
expect(vm.$el.textContent).toBe('2')
vm.a = 3
expect(vm.$el.textContent).toBe('2')

await nextTick()
expect(vm.$el.textContent).toBe('3')
})
})

0 comments on commit 85ffede

Please sign in to comment.