Repository navigation
fix: preserve enumerable symbols when cloning patch values - #1354
Open
wozhenbang2004 wants to merge 4 commits into
Open
wozhenbang2004 wants to merge 4 commits into
wozhenbang2004 wants to merge 4 commits into
Conversation
Deep-clone own enumerable symbol properties so applying object patch values retains their data.
Cover add, replace, inverse patches, and deep clone isolation for nested enumerable symbol properties.
mweststrate
requested changes
Nov 10, 2026
mweststrate
left a comment
Collaborator
There was a problem hiding this comment.
Probably the fix should respect the setUseStrictShallowCopy flag for consistent behavior with normal recipes.
| if (isSet(obj)) return new Set(Array.from(obj).map(deepClonePatchValue)) | ||
| const cloned = Object.create(getPrototypeOf(obj)) | ||
| for (const key in obj) cloned[key] = deepClonePatchValue(obj[key]) | ||
| for (const key of Object.getOwnPropertySymbols(obj)) { |
Collaborator
There was a problem hiding this comment.
The main package iteration is determined by the flag setUseStrictShallowCopy . Please make sure the code here is consistent with that. Probably easiest to prove by rewriting the test to use the test helper runPatchTests with the option enabled and disabled.
This branch has not been deployed
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.
Applying an object patch value drops its enumerable symbol properties because
deepClonePatchValueonly iterates string keys. A value produced byproduceWithPatchescan therefore differ from replaying its patches.Clone own enumerable symbols recursively alongside the existing string-key handling. Non-enumerable symbols remain excluded, and the existing class prototype and
immerablehandling are preserved.Tests cover add, replace, inverse patches, and nested symbol-value clone isolation.
Validation: source suite and coverage (4,215 passed, 8 skipped), production-build suite (3,664 passed, 8 skipped), build including declarations, Flow (0 errors), performance suite, Prettier, and diff checks.