@tanstack/router-core 1.125.4 → 1.126.2
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/RouterProvider.d.cts +1 -0
- package/dist/cjs/router.cjs +18 -8
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/cjs/router.d.cts +1 -0
- package/dist/esm/RouterProvider.d.ts +1 -0
- package/dist/esm/router.d.ts +1 -0
- package/dist/esm/router.js +18 -8
- package/dist/esm/router.js.map +1 -1
- package/package.json +1 -1
- package/src/RouterProvider.ts +1 -0
- package/src/router.ts +26 -7
package/package.json
CHANGED
package/src/RouterProvider.ts
CHANGED
package/src/router.ts
CHANGED
|
@@ -441,6 +441,7 @@ export interface BuildNextOptions {
|
|
|
441
441
|
href?: string
|
|
442
442
|
_fromLocation?: ParsedLocation
|
|
443
443
|
unsafeRelative?: 'path'
|
|
444
|
+
_isNavigate?: boolean
|
|
444
445
|
}
|
|
445
446
|
|
|
446
447
|
type NavigationEventInfo = {
|
|
@@ -1419,11 +1420,11 @@ export class RouterCore<
|
|
|
1419
1420
|
// We allow the caller to override the current location
|
|
1420
1421
|
const currentLocation = dest._fromLocation || this.latestLocation
|
|
1421
1422
|
|
|
1422
|
-
const
|
|
1423
|
+
const allCurrentLocationMatches = this.matchRoutes(currentLocation, {
|
|
1423
1424
|
_buildLocation: true,
|
|
1424
1425
|
})
|
|
1425
1426
|
|
|
1426
|
-
const lastMatch = last(
|
|
1427
|
+
const lastMatch = last(allCurrentLocationMatches)!
|
|
1427
1428
|
|
|
1428
1429
|
// First let's find the starting pathname
|
|
1429
1430
|
// By default, start with the current location
|
|
@@ -1442,12 +1443,29 @@ export class RouterCore<
|
|
|
1442
1443
|
fromPath = currentLocation.pathname
|
|
1443
1444
|
} else if (routeIsChanging && dest.from) {
|
|
1444
1445
|
fromPath = dest.from
|
|
1445
|
-
const existingFrom = [...allFromMatches].reverse().find((d) => {
|
|
1446
|
-
return this.comparePaths(d.fullPath, fromPath)
|
|
1447
|
-
})
|
|
1448
1446
|
|
|
1449
|
-
|
|
1450
|
-
|
|
1447
|
+
// do this check only on navigations during test or development
|
|
1448
|
+
if (process.env.NODE_ENV !== 'production' && dest._isNavigate) {
|
|
1449
|
+
const allFromMatches = this.getMatchedRoutes(
|
|
1450
|
+
dest.from,
|
|
1451
|
+
undefined,
|
|
1452
|
+
).matchedRoutes
|
|
1453
|
+
|
|
1454
|
+
const matchedFrom = [...allCurrentLocationMatches]
|
|
1455
|
+
.reverse()
|
|
1456
|
+
.find((d) => {
|
|
1457
|
+
return this.comparePaths(d.fullPath, fromPath)
|
|
1458
|
+
})
|
|
1459
|
+
|
|
1460
|
+
const matchedCurrent = [...allFromMatches].reverse().find((d) => {
|
|
1461
|
+
return this.comparePaths(d.fullPath, currentLocation.pathname)
|
|
1462
|
+
})
|
|
1463
|
+
|
|
1464
|
+
// for from to be invalid it shouldn't just be unmatched to currentLocation
|
|
1465
|
+
// but the currentLocation should also be unmatched to from
|
|
1466
|
+
if (!matchedFrom && !matchedCurrent) {
|
|
1467
|
+
console.warn(`Could not find match for from: ${fromPath}`)
|
|
1468
|
+
}
|
|
1451
1469
|
}
|
|
1452
1470
|
}
|
|
1453
1471
|
|
|
@@ -1777,6 +1795,7 @@ export class RouterCore<
|
|
|
1777
1795
|
...rest,
|
|
1778
1796
|
href,
|
|
1779
1797
|
to: to as string,
|
|
1798
|
+
_isNavigate: true,
|
|
1780
1799
|
})
|
|
1781
1800
|
}
|
|
1782
1801
|
|