ソースを参照

Let s try it...

sebavan 5 年 前
コミット
de5c8a5f38
1 ファイル変更15 行追加1 行削除
  1. 15 1
      src/Misc/deepCopier.ts

+ 15 - 1
src/Misc/deepCopier.ts

@@ -18,6 +18,20 @@ var cloneValue = (source: any, destinationObject: any) => {
     return null;
 };
 
+function getAllPropertyNames(obj: any): string[] {
+    const props: string[] = [];
+
+    do {
+        Object.getOwnPropertyNames(obj).forEach(function(prop) {
+            if (props.indexOf(prop) === -1) {
+                props.push(prop);
+            }
+        });
+    } while (obj = Object.getPrototypeOf(obj));
+
+    return props;
+}
+
 /**
  * Class containing a set of static utilities functions for deep copy.
  */
@@ -30,7 +44,7 @@ export class DeepCopier {
      * @param mustCopyList defines a list of properties to copy (even if they start with _)
      */
     public static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void {
-        for (var prop in source) {
+        for (var prop in getAllPropertyNames(source)) {
 
             if (prop[0] === "_" && (!mustCopyList || mustCopyList.indexOf(prop) === -1)) {
                 continue;