Skip to content

fix: handle custom classes with null proto as pojo#95

Merged
Rich-Harris merged 3 commits into
sveltejs:mainfrom
pi0:fix/null-proto-class
Aug 26, 2025
Merged

fix: handle custom classes with null proto as pojo#95
Rich-Harris merged 3 commits into
sveltejs:mainfrom
pi0:fix/null-proto-class

Conversation

@pi0

@pi0 pi0 commented Apr 8, 2025

Copy link
Copy Markdown
Contributor

There is a common pattern that libraries like ufo and cookie use to have a custom class with null prototype instead of Object.create(null) to improve (v8) performance.

This PR fixes the devalue behavior to support this pattern.

Since there is no obvious way to distinguish {} and new NullProto() (both have prototype of [Object: null prototype]), they are serialized as normal object (with prop oveerrides)

@changeset-bot

changeset-bot Bot commented Aug 26, 2025

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 2dfa504

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@Rich-Harris Rich-Harris left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you!

@Rich-Harris Rich-Harris merged commit 8d83fb9 into sveltejs:main Aug 26, 2025
3 checks passed
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.

2 participants