File tree Expand file tree Collapse file tree 3 files changed +41
-0
lines changed
Expand file tree Collapse file tree 3 files changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ if (currentVue && typeof window !== 'undefined' && window.Vue) {
2121}
2222
2323export default plugin
24+ export { nextTick } from './nextTick'
2425export { default as createElement } from './createElement'
2526export { SetupContext }
2627export {
Original file line number Diff line number Diff line change 1+ import Vue from 'vue'
2+ import { currentVue } from './runtimeContext'
3+
4+ type NextTick = Vue [ '$nextTick' ]
5+
6+ export const nextTick : NextTick = function nextTick (
7+ this : ThisType < NextTick > ,
8+ ...args : Parameters < NextTick >
9+ ) {
10+ return currentVue ?. nextTick . bind ( this , args )
11+ } as any
Original file line number Diff line number Diff line change 1+ const Vue = require ( 'vue/dist/vue.common.js' )
2+ const { ref, nextTick } = require ( '../src' )
3+
4+ describe ( 'nextTick' , ( ) => {
5+ it ( 'should works' , ( ) => {
6+ const vm = new Vue ( {
7+ template : `<div>{{a}}</div>` ,
8+ setup ( ) {
9+ return {
10+ a : ref ( 1 ) ,
11+ }
12+ } ,
13+ } ) . $mount ( )
14+
15+ expect ( vm . $el . textContent ) . toBe ( '1' )
16+ vm . a = 2
17+ expect ( vm . $el . textContent ) . toBe ( '1' )
18+
19+ nextTick ( ( ) => {
20+ expect ( vm . $el . textContent ) . toBe ( '2' )
21+ vm . a = 3
22+ expect ( vm . $el . textContent ) . toBe ( '2' )
23+
24+ nextTick ( ( ) => {
25+ expect ( vm . $el . textContent ) . toBe ( '3' )
26+ } )
27+ } )
28+ } )
29+ } )
You can’t perform that action at this time.
0 commit comments