UNPKG

623 BJavaScriptView Raw
1import nextTick from './next-tick'
2import { updateComponent } from './lifecycle'
3
4let items = []
5
6export function enqueueRender (component, isForceUpdate = false) {
7 // tslint:disable-next-line:no-conditional-assignment
8 component._isForceUpdate = isForceUpdate
9 if (!component._dirty && (component._dirty = true) && items.push(component) === 1) {
10 nextTick(() => {
11 rerender()
12 })
13 }
14}
15
16export function rerender () {
17 let p
18 const list = items
19 items = []
20 // tslint:disable-next-line:no-conditional-assignment
21 while ((p = list.pop())) {
22 if (p._dirty) {
23 updateComponent(p, true)
24 }
25 }
26}