-
Notifications
You must be signed in to change notification settings - Fork 344
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: export nextTick * chore: update
- Loading branch information
Showing
3 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import Vue from 'vue' | ||
import { currentVue } from './runtimeContext' | ||
|
||
type NextTick = Vue['$nextTick'] | ||
|
||
export const nextTick: NextTick = function nextTick( | ||
this: ThisType<NextTick>, | ||
...args: Parameters<NextTick> | ||
) { | ||
return currentVue?.nextTick.bind(this, args) | ||
} as any |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
const Vue = require('vue/dist/vue.common.js') | ||
const { ref, nextTick } = require('../src') | ||
|
||
describe('nextTick', () => { | ||
it('should works', () => { | ||
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') | ||
|
||
nextTick(() => { | ||
expect(vm.$el.textContent).toBe('2') | ||
vm.a = 3 | ||
expect(vm.$el.textContent).toBe('2') | ||
|
||
nextTick(() => { | ||
expect(vm.$el.textContent).toBe('3') | ||
}) | ||
}) | ||
}) | ||
}) |