Fix domFor hitting null dom elements in while loop #3013
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
The
domFor
while loop assumes that dom will always be not null, but it seems like some environments (like happy-dom) may incorrectly report the domSize when the underlying siblings contain nulls.Motivation and Context
I believe this fixes #2990, at least based on my testing.
Also, looking at the diff between 2.2.2 and 2.2.3 (when I think this behavior was introduced), the loop here that
domFor
replaced seems to check the child nodes for nulls:v2.2.2...v2.2.3#diff-f50a6d08fa58d22d2e71df97ae8fc5727ea53bc49c69f457ef12bc6df3c6870bL583
I think this behavior was missed in the
domFor
implementation.How Has This Been Tested?
I previously had a bunch of breaking components with Mithril 2.2.3+ and happy-dom. Upon investigation, it was happening with conditional component removals via ternaries. This change fixes all of my tests.
Types of changes
Checklist