Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -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())) {
Expand All @@ -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);
}
}
}
Expand Down