diff --git a/src/component.js b/src/component.js index 565b58b519..b243755805 100644 --- a/src/component.js +++ b/src/component.js @@ -205,10 +205,16 @@ export function enqueueRender(c) { } } +/** + * @param {import('./internal').Component} a + * @param {import('./internal').Component} b + */ +const depthSort = (a, b) => a._vnode._depth - b._vnode._depth; + /** Flush the render queue by rerendering all queued components */ function process() { let c; - rerenderQueue.sort((a, b) => a._vnode._depth - b._vnode._depth); + rerenderQueue.sort(depthSort); // Don't update `renderCount` yet. Keep its value non-zero to prevent unnecessary // process() calls from getting scheduled while `queue` is still being consumed. while ((c = rerenderQueue.shift())) { @@ -219,7 +225,7 @@ function process() { // When i.e. rerendering a provider additional new items can be injected, we want to // keep the order from top to bottom with those new items so we can handle them in a // single pass - rerenderQueue.sort((a, b) => a._vnode._depth - b._vnode._depth); + rerenderQueue.sort(depthSort); } } }