Skip to content

fix: preserve assignments that shadow inherited values - #1305

Open
jakezwang wants to merge 1 commit into
immerjs:mainfrom
jakezwang:fix-inherited-value-assignment
Open

jakezwang wants to merge 1 commit into
immerjs:mainfrom
jakezwang:fix-inherited-value-assignment

Conversation

@jakezwang

Copy link
Copy Markdown

Assigning a prototype's existing value to a draft should create an own property. Currently, draft.name = "default" is ignored when name: "default" is inherited; the result has no own name and no corresponding patch.

Only skip equal-value assignments when the property is already owned by the base or copy. This also covers inherited NaN values and drafts that were modified earlier in the recipe.

Tests check property ownership, prototype preservation, and forward/inverse patches. Validation: yarn test, yarn coverage, and yarn test:perf on Node 24.21.0; the same checks also passed on Node 22.23.2.

This branch has not been deployed

No deployments
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.

1 participant