Browse Source

deepClone fix

Alexander Rose 5 years ago
parent
commit
18952ee2bd
1 changed files with 2 additions and 1 deletions
  1. 2 1
      src/mol-util/object.ts

+ 2 - 1
src/mol-util/object.ts

@@ -85,7 +85,8 @@ export function deepClone<T>(source: T): T {
         return copy as any as T;
     }
 
-    if (source instanceof Object) {
+    // `instanceof Object` does not find `Object.create(null)`
+    if (typeof source === 'object' && !('prototype' in source)) {
         const copy: { [k: string]: any } = {};
         for (let k in source) {
             if (hasOwnProperty.call(source, k)) copy[k] = deepClone(source[k]);