Skip to content
Myr

fix: make sure isPlainObject checks support objects send accross frames. Fixes #766 / #405

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by xyh · committed by GitHub · parent f8b77d1 · Browse files · 1 file+10 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Trailers

  • Co-authored-by: Yuehan Xu <yuex@microsoft.com>

Diff stats

1 file+10 added−1 removed

  • other:+10 added−1 removed

1 file+10 added−1 removed

modified:src/utils/common.ts+10 added-1 removed
34 unmodified lines
35 isSet(value)36 )37}3839const objectCtorString = Object.prototype.constructor.toString()40/*#__PURE__*/41export function isPlainObject(value: any): boolean {42 if (!value || typeof value !== "object") return false43 const proto = Object.getPrototypeOf(value)43 return !proto || proto === Object.prototype44 if (proto === null) {45 return true46 }47 const Ctor =48 Object.hasOwnProperty.call(proto, "constructor") && proto.constructor49 return (50 typeof Ctor == "function" &&51 Function.toString.call(Ctor) === objectCtorString52 )53}5455/** Get the underlying object that is represented by the given draft */56/*#__PURE__*/
161 unmodified lines