@tanstack/router-core 1.158.4 → 1.159.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/router.cjs +8 -5
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/esm/router.js +8 -5
- package/dist/esm/router.js.map +1 -1
- package/package.json +1 -1
- package/src/router.ts +12 -10
package/package.json
CHANGED
package/src/router.ts
CHANGED
|
@@ -1401,6 +1401,10 @@ export class RouterCore<
|
|
|
1401
1401
|
|
|
1402
1402
|
const matches = new Array<AnyRouteMatch>(matchedRoutes.length)
|
|
1403
1403
|
|
|
1404
|
+
const previousMatchesByRouteId = new Map(
|
|
1405
|
+
this.state.matches.map((match) => [match.routeId, match]),
|
|
1406
|
+
)
|
|
1407
|
+
|
|
1404
1408
|
for (let index = 0; index < matchedRoutes.length; index++) {
|
|
1405
1409
|
const route = matchedRoutes[index]!
|
|
1406
1410
|
// Take each matched route and resolve + validate its search params
|
|
@@ -1484,9 +1488,7 @@ export class RouterCore<
|
|
|
1484
1488
|
|
|
1485
1489
|
const existingMatch = this.getMatch(matchId)
|
|
1486
1490
|
|
|
1487
|
-
const previousMatch =
|
|
1488
|
-
(d) => d.routeId === route.id,
|
|
1489
|
-
)
|
|
1491
|
+
const previousMatch = previousMatchesByRouteId.get(route.id)
|
|
1490
1492
|
|
|
1491
1493
|
const strictParams = existingMatch?._strictParams ?? usedParams
|
|
1492
1494
|
|
|
@@ -1520,9 +1522,7 @@ export class RouterCore<
|
|
|
1520
1522
|
match = {
|
|
1521
1523
|
...existingMatch,
|
|
1522
1524
|
cause,
|
|
1523
|
-
params: previousMatch
|
|
1524
|
-
? replaceEqualDeep(previousMatch.params, routeParams)
|
|
1525
|
-
: routeParams,
|
|
1525
|
+
params: previousMatch?.params ?? routeParams,
|
|
1526
1526
|
_strictParams: strictParams,
|
|
1527
1527
|
search: previousMatch
|
|
1528
1528
|
? replaceEqualDeep(previousMatch.search, preMatchSearch)
|
|
@@ -1543,9 +1543,7 @@ export class RouterCore<
|
|
|
1543
1543
|
ssr: (isServer ?? this.isServer) ? undefined : route.options.ssr,
|
|
1544
1544
|
index,
|
|
1545
1545
|
routeId: route.id,
|
|
1546
|
-
params: previousMatch
|
|
1547
|
-
? replaceEqualDeep(previousMatch.params, routeParams)
|
|
1548
|
-
: routeParams,
|
|
1546
|
+
params: previousMatch?.params ?? routeParams,
|
|
1549
1547
|
_strictParams: strictParams,
|
|
1550
1548
|
pathname: interpolatedPath,
|
|
1551
1549
|
updatedAt: Date.now(),
|
|
@@ -1605,7 +1603,11 @@ export class RouterCore<
|
|
|
1605
1603
|
const route = this.looseRoutesById[match.routeId]!
|
|
1606
1604
|
const existingMatch = this.getMatch(match.id)
|
|
1607
1605
|
|
|
1608
|
-
//
|
|
1606
|
+
// Update the match's params
|
|
1607
|
+
const previousMatch = previousMatchesByRouteId.get(match.routeId)
|
|
1608
|
+
match.params = previousMatch
|
|
1609
|
+
? replaceEqualDeep(previousMatch.params, routeParams)
|
|
1610
|
+
: routeParams
|
|
1609
1611
|
|
|
1610
1612
|
if (!existingMatch) {
|
|
1611
1613
|
const parentMatch = matches[index - 1]
|