@@ -2,7 +2,7 @@ import { assign } from './util';
22import { diff , commitRoot } from './diff/index' ;
33import options from './options' ;
44import { Fragment } from './create-element' ;
5- import { EMPTY_ARR , MODE_HYDRATE } from './constants' ;
5+ import { MODE_HYDRATE } from './constants' ;
66
77/**
88 * Base Component class. Provides `setState()` and `forceUpdate()`, which
@@ -120,10 +120,12 @@ export function getDomSibling(vnode, childIndex) {
120120 * Trigger in-place re-rendering of a component.
121121 * @param {Component } component The component to rerender
122122 */
123- function renderComponent ( component , commitQueue , refQueue ) {
123+ function renderComponent ( component ) {
124124 let oldVNode = component . _vnode ,
125125 oldDom = oldVNode . _dom ,
126- parentDom = component . _parentDom ;
126+ parentDom = component . _parentDom ,
127+ commitQueue = [ ] ,
128+ refQueue = [ ] ;
127129
128130 if ( parentDom ) {
129131 const newVNode = assign ( { } , oldVNode ) ;
@@ -145,14 +147,11 @@ function renderComponent(component, commitQueue, refQueue) {
145147
146148 newVNode . _original = oldVNode . _original ;
147149 newVNode . _parent . _children [ newVNode . _index ] = newVNode ;
148-
149- newVNode . _nextDom = undefined ;
150+ commitRoot ( commitQueue , newVNode , refQueue ) ;
150151
151152 if ( newVNode . _dom != oldDom ) {
152153 updateParentDomPointers ( newVNode ) ;
153154 }
154-
155- return newVNode ;
156155 }
157156}
158157
@@ -222,33 +221,21 @@ const depthSort = (a, b) => a._vnode._depth - b._vnode._depth;
222221/** Flush the render queue by rerendering all queued components */
223222function process ( ) {
224223 let c ;
225- let commitQueue = [ ] ;
226- let refQueue = [ ] ;
227- let root ;
228224 rerenderQueue . sort ( depthSort ) ;
229225 // Don't update `renderCount` yet. Keep its value non-zero to prevent unnecessary
230226 // process() calls from getting scheduled while `queue` is still being consumed.
231227 while ( ( c = rerenderQueue . shift ( ) ) ) {
232228 if ( c . _dirty ) {
233229 let renderQueueLength = rerenderQueue . length ;
234- root = renderComponent ( c , commitQueue , refQueue ) || root ;
235- // If this WAS the last component in the queue, run commit callbacks *before* we exit the tight loop.
236- // This is required in order for `componentDidMount(){this.setState()}` to be batched into one flush.
237- // Otherwise, also run commit callbacks if the render queue was mutated.
238- if ( renderQueueLength === 0 || rerenderQueue . length > renderQueueLength ) {
239- commitRoot ( commitQueue , root , refQueue ) ;
240- refQueue . length = commitQueue . length = 0 ;
241- root = undefined ;
230+ renderComponent ( c ) ;
231+ if ( rerenderQueue . length > renderQueueLength ) {
242232 // When i.e. rerendering a provider additional new items can be injected, we want to
243233 // keep the order from top to bottom with those new items so we can handle them in a
244234 // single pass
245235 rerenderQueue . sort ( depthSort ) ;
246- } else if ( root ) {
247- if ( options . _commit ) options . _commit ( root , EMPTY_ARR ) ;
248236 }
249237 }
250238 }
251- if ( root ) commitRoot ( commitQueue , root , refQueue ) ;
252239 process . _rerenderCount = 0 ;
253240}
254241
0 commit comments