@tanstack/router-core 1.139.1 → 1.139.3
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 +18 -1
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/esm/router.js +18 -1
- package/dist/esm/router.js.map +1 -1
- package/package.json +1 -1
- package/src/router.ts +21 -1
package/dist/esm/router.js
CHANGED
|
@@ -526,7 +526,7 @@ class RouterCore {
|
|
|
526
526
|
});
|
|
527
527
|
return commitPromise;
|
|
528
528
|
};
|
|
529
|
-
this.navigate = ({ to, reloadDocument, href, ...rest }) => {
|
|
529
|
+
this.navigate = async ({ to, reloadDocument, href, ...rest }) => {
|
|
530
530
|
if (!reloadDocument && href) {
|
|
531
531
|
try {
|
|
532
532
|
new URL(`${href}`);
|
|
@@ -539,6 +539,23 @@ class RouterCore {
|
|
|
539
539
|
const location = this.buildLocation({ to, ...rest });
|
|
540
540
|
href = location.url;
|
|
541
541
|
}
|
|
542
|
+
if (!rest.ignoreBlocker) {
|
|
543
|
+
const historyWithBlockers = this.history;
|
|
544
|
+
const blockers = historyWithBlockers.getBlockers?.() ?? [];
|
|
545
|
+
for (const blocker of blockers) {
|
|
546
|
+
if (blocker?.blockerFn) {
|
|
547
|
+
const shouldBlock = await blocker.blockerFn({
|
|
548
|
+
currentLocation: this.latestLocation,
|
|
549
|
+
nextLocation: this.latestLocation,
|
|
550
|
+
// External URLs don't have a next location in our router
|
|
551
|
+
action: "PUSH"
|
|
552
|
+
});
|
|
553
|
+
if (shouldBlock) {
|
|
554
|
+
return Promise.resolve();
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
}
|
|
542
559
|
if (rest.replace) {
|
|
543
560
|
window.location.replace(href);
|
|
544
561
|
} else {
|