Skip to content

Commit

Permalink
fix: don't use getPrototypeOf on primitives (#55)
Browse files Browse the repository at this point in the history
The specification changed to allow this but there doesn't seem to be a
polyfill for IE11 which isn't updated anymore. A part of solution to
visjs/vis-network#57 issue.
  • Loading branch information
Thomaash authored Sep 3, 2019
1 parent 456b67b commit 39c6d07
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,11 +388,16 @@ export function deepExtend(
): any {
for (const prop in b) {
if (Object.prototype.hasOwnProperty.call(b, prop) || protoExtend === true) {
if (b[prop] && Object.getPrototypeOf(b[prop]) === Object.prototype) {
if (
typeof b[prop] === "object" &&
b[prop] !== null &&
Object.getPrototypeOf(b[prop]) === Object.prototype
) {
if (a[prop] === undefined) {
a[prop] = deepExtend({}, b[prop], protoExtend); // NOTE: allowDeletion not propagated!
} else if (
a[prop] &&
typeof a[prop] === "object" &&
a[prop] !== null &&
Object.getPrototypeOf(a[prop]) === Object.prototype
) {
deepExtend(a[prop], b[prop], protoExtend); // NOTE: allowDeletion not propagated!
Expand Down

0 comments on commit 39c6d07

Please sign in to comment.