solid icon indicating copy to clipboard operation
solid copied to clipboard

createMutable / createStore calling hasOwnProperty throw error (".hasOwnProperty is not a function")

Open LiQuidProQuo opened this issue 3 years ago • 1 comments

Describe the bug

The issue reported for hasOwnProperty, but it applies to other properties that are only defined up in the prototype chain the issue was reproduced with createMutable, but is also applicable for createStore

calling hasOwnProperty on a mutable store, throws an error

const mutable = createMutable({ A: "1" });

// will throw
mutable.hasOwnProperty('A')

Your Example Website or App

https://playground.solidjs.com/?hash=217546618&version=1.4.1

Steps to Reproduce the Bug or Issue

see playground

Expected behavior

hasOwnProperty should work similarly to using in

const mutable = createMutable({ A: "1" });

// will not throw, but is not identical to hasOwnProperty( does not lookup the prototype chain)
let hasA = 'A' in mutable

Fix

https://github.com/solidjs/solid/commit/30b0853525fdaee937140d2e678de87c0a6459e8

LiQuidProQuo avatar Jul 12 '22 20:07 LiQuidProQuo

Hopefully this will seem obvious, but I appreciate that commit 30b0853 also fixed this for createStore() since I just came over here to report that bug myself.

jorroll avatar Jul 20 '22 13:07 jorroll