Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Object values of a Map are not frozen anymore #1119

Open
1 task done
alexlazau opened this issue Apr 26, 2024 · 2 comments · May be fixed by #1150
Open
1 task done

Object values of a Map are not frozen anymore #1119

alexlazau opened this issue Apr 26, 2024 · 2 comments · May be fixed by #1150
Labels

Comments

@alexlazau
Copy link

🐛 Bug Report

Starting with Immer 10.0.4, enableMapSet() does not seem to work as expected as values (if objects) of a native Map aren't frozen anymore.

Link to repro

https://stackblitz.com/edit/immer-10-0-4-map-bug

To Reproduce

Create a Map with objects by using produce and check the values of the Map with Object.isFrozen(...).

Observed behavior

Objects inside a Map are not frozen.

Expected behavior

Objects inside a Map are frozen. The provided repo works if the Immer version is set to 10.0.3.

Environment

  • Immer version: 10.0.4
  • I filed this report against the latest version of Immer
@mweststrate
Copy link
Collaborator

Note to self, see also #1069

@mweststrate
Copy link
Collaborator

Thanks for the detailed report, will investigate at a later point.

Chetan-Satpute added a commit to Chetan-Satpute/immer that referenced this issue Nov 15, 2024
Map keys are not enumerable properties of the Map object, so the propertyIsEnumerable check does not apply to them.

This commit adds a condition to detect Map objects and uses Map.prototype.has to check for key existence.

Fixes immerjs#1119.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants