Make vnode.domSize assignment consistent between create and update.#3055
Merged
dead-claudia merged 3 commits intoMithrilJS:mainfrom Nov 8, 2025
Merged
Make vnode.domSize assignment consistent between create and update.#3055dead-claudia merged 3 commits intoMithrilJS:mainfrom
vnode.domSize assignment consistent between create and update.#3055dead-claudia merged 3 commits intoMithrilJS:mainfrom
Conversation
dead-claudia
requested changes
Nov 5, 2025
Member
dead-claudia
left a comment
There was a problem hiding this comment.
Could you add new tests to verify this behavior? It's clearly a bug fix, so I'd like tests to make sure it doesn't regress further.
Contributor
Author
|
@dead-claudia Thank you for your review. Edit: I also added test cases for consistency of |
c442b2e to
f6ac3c8
Compare
dead-claudia
approved these changes
Nov 8, 2025
For fragment and component vnodes, the assignment of `vnode.domSize` was inconsistent between create and update. In particular, when the fragment vnode corresponded to exactly one DOM node, it was set to `1` on creation but left `undefined` on update. Although leaving it undefined in the single-node case was intentional, it reduced behavioral consistency and code readability. This commit aligns the behavior between creation and update. To minimize internal impact from `domSize` transitioning from `undefined` to `1`, additional checks were added in the move and remove paths.
This was a supplemental comment about capturing DOM nodes in `vnode.instance`, but the related code has already been removed.
f6ac3c8 to
18b47e9
Compare
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR makes the code and behavior of create and update processes more consistent.
Description
vnode.domSizeinupdateFragmentis now always set to an integer and not leftundefined.createFragment,vnode.domSizeis always an integer (temp.childNodes.length), soupdateFragmentfollows it.vnode.domSize === 1have been added tomoveDOMandremoveDOM.vnode.domSizeandvnode.domassignment code increateComponentandupdateComponentare now consistent.The behavior remains unchanged except that
vnode.domSize, which was intentionallyundefined, will now be set to 1.npm run testpasses as is.Also, unnecessary a comment immediately after
vnode.domSizeincreateHTMLhas been removed as well.Motivation and Context
This PR fixes inconsistencies in domSize for the following create and update processes:
flems
For component vnodes, the code was redundant in both create and update, so I made it simpler and consistent.
Also, the bundle size becomes 8,952 bytes gzipped.
How Has This Been Tested?
npm run testTypes of changes
Checklist