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

[Bug] Maps and Sets are polluted with _constructor-name_ property #104

Open
justinfagnani opened this issue Aug 26, 2024 · 0 comments
Open
Labels
bug Something isn't working

Comments

@justinfagnani
Copy link

Describe the bug

In Storybook, any story arguments that are or contain Maps, Sets, and possibly instances of other classes, have a spurious _constructor-name_ property added to them.

This can interfere with code that's dealing with properties of object generically.

Steps to reproduce the behavior

  1. Make a component that displays Object.getOwnPropertyKeys() of an argument
  2. Use the component in a story with a Map as the argument
  3. See _constructor-name_ show up even though neither the story code nor the component added it.

The culprit appears to be here:

Object.assign(converted, { '_constructor-name_': value.constructor.name });

Expected behavior

Serialized objects are not mutated. Deserialized objects don't have extra properties.

A serialization library should not be modifying the objects sent tone serialized. If these are deserialized objects, then special JSON properties should be excluded from the serialization.

Screenshots and/or logs

Here's a screen shot of an object-inspector widget I'm building that's showing these extra properties inside Storybook:

Screenshot 2024-08-26 at 11 01 21 AM

Environment

Not an environment-specific issue.

Additional context

This bug has been reported multiple times on Storybook:

@justinfagnani justinfagnani added the bug Something isn't working label Aug 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants
@justinfagnani and others