-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
don't relink customdata, ids, or any matching objects
- Loading branch information
1 parent
8a7ed36
commit 95d540e
Showing
2 changed files
with
112 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,9 @@ module.exports = function relinkPrivateKeys(toContainer, fromContainer) { | |
fromVal = fromContainer[k], | ||
toVal = toContainer[k]; | ||
|
||
if(toVal === fromVal) { | ||
continue; | ||
} | ||
if(k.charAt(0) === '_' || typeof fromVal === 'function') { | ||
|
||
// if it already exists at this point, it's something | ||
|
@@ -37,9 +40,14 @@ module.exports = function relinkPrivateKeys(toContainer, fromContainer) { | |
} | ||
else if(isArray(fromVal) && isArray(toVal) && isPlainObject(fromVal[0])) { | ||
|
||
// filter out data_array items that can contain user objects | ||
// most of the time the toVal === fromVal check will catch these early | ||
// but if the user makes new ones we also don't want to recurse in. | ||
if(k === 'customdata' || k === 'ids') continue; | ||
|
||
// recurse into arrays containers | ||
for(var j = 0; j < fromVal.length; j++) { | ||
if(isPlainObject(fromVal[j]) && isPlainObject(toVal[j])) { | ||
if(isPlainObject(fromVal[j]) && isPlainObject(toVal[j]) && (toVal[j] !== fromVal[j])) { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
alexcjohnson
Author
Collaborator
|
||
relinkPrivateKeys(toVal[j], fromVal[j]); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@alexcjohnson One small suggestion: do the inequality check first? (I'm assuming the inequality check is faster than the
isPlainObject()
calls.)