Skip to content

Commit

Permalink
backport #3921
Browse files Browse the repository at this point in the history
  • Loading branch information
JoviDeCroock committed Jan 16, 2024
1 parent 26a4c28 commit f9b7ab9
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,16 @@ export function enqueueRender(internal) {
}
}

/**
* @param {import('./internal').Internal} a
* @param {import('./internal').Internal} b
*/
const depthSort = (a, b) => a._depth - b._depth;

/** Flush the render queue by rerendering all queued components */
function processRenderQueue() {
let c;
renderQueue.sort((a, b) => a._depth - b._depth);
renderQueue.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 = renderQueue.shift())) {
Expand All @@ -155,7 +161,7 @@ function processRenderQueue() {
// 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
renderQueue.sort((a, b) => a._depth - b._depth);
renderQueue.sort(depthSort);
}
}
}
Expand Down

0 comments on commit f9b7ab9

Please sign in to comment.