浏览代码

deepClone fix

Alexander Rose 5 年之前
父节点
当前提交
18952ee2bd
共有 1 个文件被更改,包括 2 次插入1 次删除
  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]);