Skip to content

Commit 0a6b897

Browse files
authored
fix: isPlainObject incorrectly identifies objects wrapped in a Proxy object in Safari 10 (#1378) (#1379)
1 parent 07d4a0a commit 0a6b897

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

packages/shared/src/utils.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,11 @@ export const objectToString = Object.prototype.toString
151151
export const toTypeString = (value: unknown): string =>
152152
objectToString.call(value)
153153

154-
export const isPlainObject = (val: unknown): val is object =>
155-
toTypeString(val) === '[object Object]'
154+
export const isPlainObject = (val: unknown): val is object => {
155+
if (!isObject(val)) return false
156+
const proto = Object.getPrototypeOf(val)
157+
return proto === null || proto.constructor === Object
158+
}
156159

157160
// for converting list and named values to displayed strings.
158161
export const toDisplayString = (val: unknown): string => {

0 commit comments

Comments
 (0)