Skip to content

Sort new renderqueue items#2396

Merged
marvinhagemeister merged 7 commits intopreactjs:masterfrom
jviide:sort-new-renderqueue-items
Mar 6, 2020
Merged

Sort new renderqueue items#2396
marvinhagemeister merged 7 commits intopreactjs:masterfrom
jviide:sort-new-renderqueue-items

Conversation

@jviide
Copy link
Copy Markdown
Contributor

@jviide jviide commented Mar 6, 2020

This pull request attempts to fix #2393 by modifying how the global renderQueue is processed.

Currently renderQueue is sorted by vnode depth before its items are processed, but if new items get queued during processing (and renderQueue.length > 1) then those new items are also processed without them getting sorted by depth first.

This pull attempts fixing that. When renderQueue is processed, it's item count is checked. If there are no items then we can stop. Otherwise the queue is sorted by depth and stored into a temporary variable while renderQueue itself is reinitialized with a new, empty array. Now the "old" queued items get processed and any new items get added to the new renderQueue list.

After the all old items have been processed the new renderQueue is checked & sorted again, and the cycle starts anew.

A great test from @JoviDeCroock's alternative PR #2395 is also included here.

Fixes #2393

@coveralls
Copy link
Copy Markdown

coveralls commented Mar 6, 2020

Coverage Status

Coverage increased (+0.2%) to 99.793% when pulling 58619d1 on jviide:sort-new-renderqueue-items into 0aaa855 on preactjs:master.

Comment thread src/component.js
Copy link
Copy Markdown
Member

@JoviDeCroock JoviDeCroock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one!

Copy link
Copy Markdown
Member

@marvinhagemeister marvinhagemeister left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is so good!! Really excited about this PR 🙌 ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

createContext is not fully React compatible

4 participants