Skip to content

fix: use Object.prototype.hasOwnProperty.call for null-prototype store objects#2793

Open
tsushanth wants to merge 1 commit into
solidjs:mainfrom
tsushanth:fix/null-proto-hasownproperty
Open

fix: use Object.prototype.hasOwnProperty.call for null-prototype store objects#2793
tsushanth wants to merge 1 commit into
solidjs:mainfrom
tsushanth:fix/null-proto-hasownproperty

Conversation

@tsushanth

Copy link
Copy Markdown

Null-prototype objects (created with Object.create(null)) are commonly used as dictionary-style maps because they avoid inherited properties like constructor and __proto__. When a store proxy wraps such an object and a function-valued property is accessed, the proxy calls .hasOwnProperty() directly on the target. Because null-prototype objects do not inherit from Object.prototype, this throws TypeError: target.hasOwnProperty is not a function.

This patch replaces the two direct .hasOwnProperty() calls in store.ts and mutable.ts with Object.prototype.hasOwnProperty.call(target, property), which is safe regardless of the object's prototype chain.

Fixes #2771

@changeset-bot

changeset-bot Bot commented Jun 25, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: eb200e8

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

This PR includes changesets to release 2 packages
Name Type
solid-js Patch
test-integration Patch

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

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.0.0-beta.14: Null-prototype store crashes when reading a function-valued property

1 participant