chore: modify getAllPaths utility method to only create child records for native objects (#21998)

This commit is contained in:
arunvjn 2023-04-03 11:33:03 +05:30 committed by GitHub
parent 977eda6388
commit f45afd9c8f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 1 deletions

View File

@ -205,6 +205,7 @@ describe("1. Correctly handle paths", () => {
["1", "2"],
],
},
stringProperty: new String("Hello"),
},
};
const result = {
@ -221,6 +222,7 @@ describe("1. Correctly handle paths", () => {
"WidgetName.objectProperty.childObjectProperty[3]": true,
"WidgetName.objectProperty.childObjectProperty[3][0]": true,
"WidgetName.objectProperty.childObjectProperty[3][1]": true,
"WidgetName.stringProperty": true,
};
const actual = getAllPaths(myTree);

View File

@ -491,7 +491,7 @@ export const getAllPaths = (
const tempKey = curKey ? `${curKey}[${i}]` : `${i}`;
getAllPaths(records[i], tempKey, result);
}
} else if (typeof records === "object" && records) {
} else if (isTrueObject(records)) {
for (const key of Object.keys(records)) {
const tempKey = curKey ? `${curKey}.${key}` : `${key}`;
getAllPaths(records[key], tempKey, result);