@remix-run/router 1.3.1-pre.0 → 1.3.1
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/CHANGELOG.md +7 -4
- package/dist/history.d.ts +1 -1
- package/dist/router.cjs.js +12 -17
- package/dist/router.cjs.js.map +1 -1
- package/dist/router.js +12 -17
- package/dist/router.js.map +1 -1
- package/dist/router.umd.js +12 -17
- package/dist/router.umd.js.map +1 -1
- package/dist/router.umd.min.js +2 -2
- package/dist/router.umd.min.js.map +1 -1
- package/history.ts +6 -18
- package/package.json +1 -1
- package/router.ts +12 -1
package/history.ts
CHANGED
|
@@ -85,7 +85,7 @@ export interface Update {
|
|
|
85
85
|
/**
|
|
86
86
|
* The delta between this location and the former location in the history stack
|
|
87
87
|
*/
|
|
88
|
-
delta: number;
|
|
88
|
+
delta: number | null;
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
/**
|
|
@@ -612,24 +612,12 @@ function getUrlBasedHistory(
|
|
|
612
612
|
}
|
|
613
613
|
|
|
614
614
|
function handlePop() {
|
|
615
|
-
|
|
615
|
+
action = Action.Pop;
|
|
616
616
|
let nextIndex = getIndex();
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
action
|
|
621
|
-
index = nextIndex;
|
|
622
|
-
if (listener) {
|
|
623
|
-
listener({ action, location: history.location, delta });
|
|
624
|
-
}
|
|
625
|
-
} else {
|
|
626
|
-
warning(
|
|
627
|
-
false,
|
|
628
|
-
`You are trying to perform a POP navigation to a location that was not ` +
|
|
629
|
-
`created by @remix-run/router. This will fail silently in production. ` +
|
|
630
|
-
`You should navigate via the router to avoid this situation (instead of ` +
|
|
631
|
-
`using window.history.pushState/window.location.hash).`
|
|
632
|
-
);
|
|
617
|
+
let delta = nextIndex == null ? null : nextIndex - index;
|
|
618
|
+
index = nextIndex;
|
|
619
|
+
if (listener) {
|
|
620
|
+
listener({ action, location: history.location, delta });
|
|
633
621
|
}
|
|
634
622
|
}
|
|
635
623
|
|
package/package.json
CHANGED
package/router.ts
CHANGED
|
@@ -781,12 +781,23 @@ export function createRouter(init: RouterInit): Router {
|
|
|
781
781
|
return;
|
|
782
782
|
}
|
|
783
783
|
|
|
784
|
+
warning(
|
|
785
|
+
activeBlocker != null && delta === null,
|
|
786
|
+
"You are trying to use a blocker on a POP navigation to a location " +
|
|
787
|
+
"that was not created by @remix-run/router. This will fail silently in " +
|
|
788
|
+
"production. This can happen if you are navigating outside the router " +
|
|
789
|
+
"via `window.history.pushState`/`window.location.hash` instead of using " +
|
|
790
|
+
"router navigation APIs. This can also happen if you are using " +
|
|
791
|
+
"createHashRouter and the user manually changes the URL."
|
|
792
|
+
);
|
|
793
|
+
|
|
784
794
|
let blockerKey = shouldBlockNavigation({
|
|
785
795
|
currentLocation: state.location,
|
|
786
796
|
nextLocation: location,
|
|
787
797
|
historyAction,
|
|
788
798
|
});
|
|
789
|
-
|
|
799
|
+
|
|
800
|
+
if (blockerKey && delta != null) {
|
|
790
801
|
// Restore the URL to match the current UI, but don't update router state
|
|
791
802
|
ignoreNextHistoryUpdate = true;
|
|
792
803
|
init.history.go(delta * -1);
|