Skip to content

Commit 632ed4f

Browse files
Revert "refactor(treeChanges): Simplify variables when calculating tree changes"
This reverts commit f65cfb3 Also adds retainedWithToParams
1 parent bb36c71 commit 632ed4f

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/path/pathUtils.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,16 @@ export class PathUtils {
125125

126126
let from: PathNode[], retained: PathNode[], exiting: PathNode[], entering: PathNode[], to: PathNode[];
127127

128-
from = fromPath;
129-
retained = from.slice(0, keep).map(applyToParams); // applyToParams to update dynamic params
130-
exiting = from.slice(keep);
131-
entering = toPath.slice(keep);
132-
to = (retained).concat(entering);
128+
from = fromPath;
129+
retained = from.slice(0, keep);
130+
exiting = from.slice(keep);
133131

134-
return { from, to, retained, exiting, entering };
132+
// Create a new retained path (with shallow copies of nodes) which have the params of the toPath mapped
133+
const retainedWithToParams = retained.map(applyToParams);
134+
entering = toPath.slice(keep);
135+
to = (retainedWithToParams).concat(entering);
136+
137+
return { from, to, retained, retainedWithToParams, exiting, entering };
135138
}
136139

137140
/**

0 commit comments

Comments
 (0)