@real-router/angular 0.24.13 → 0.25.0
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.
|
@@ -698,6 +698,7 @@ function createViewTransitions(router) {
|
|
|
698
698
|
} };
|
|
699
699
|
}
|
|
700
700
|
const objectKeys = Object.keys;
|
|
701
|
+
const hasOwn = Object.hasOwn;
|
|
701
702
|
const ROUTER_BRAND = Symbol.for("real-router.router");
|
|
702
703
|
function isUnreadableRouter(candidate) {
|
|
703
704
|
try {
|
|
@@ -768,6 +769,23 @@ function buildHref(router, routeName, routeParams, routeSearch, hash) {
|
|
|
768
769
|
return;
|
|
769
770
|
}
|
|
770
771
|
}
|
|
772
|
+
function printsPath(router, routeName, routeParams, routeSearch, path) {
|
|
773
|
+
try {
|
|
774
|
+
const api = getPluginApi(router);
|
|
775
|
+
const forwarded = api.forwardState(routeName, routeParams, routeSearch);
|
|
776
|
+
return api.buildPathResolved(forwarded.name, forwarded.params, forwarded.search) === path;
|
|
777
|
+
} catch {
|
|
778
|
+
return false;
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
function addBypass(opts) {
|
|
782
|
+
const slots = opts;
|
|
783
|
+
putField(slots, "force", true);
|
|
784
|
+
putField(slots, "hashChange", true);
|
|
785
|
+
}
|
|
786
|
+
function callerBypasses(opts) {
|
|
787
|
+
return hasOwn(opts, "reload") && Boolean(opts.reload) || hasOwn(opts, "force") && Boolean(opts.force);
|
|
788
|
+
}
|
|
771
789
|
function navigateWithHash(router, routeName, routeParams, routeSearch, hash, extraOptions) {
|
|
772
790
|
const opts = { ...extraOptions };
|
|
773
791
|
if (hash !== void 0) putField(opts, "hash", hash);
|
|
@@ -775,12 +793,15 @@ function navigateWithHash(router, routeName, routeParams, routeSearch, hash, ext
|
|
|
775
793
|
let navigatedSearch = routeSearch;
|
|
776
794
|
if (current !== void 0) {
|
|
777
795
|
const sameLocationSearch = routeSearch ?? current.search;
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
opts
|
|
796
|
+
const sameValues = router.isActiveRoute(routeName, routeParams, sameLocationSearch, true, false);
|
|
797
|
+
const currentHash = current.context?.url?.hash ?? "";
|
|
798
|
+
if (currentHash !== (hash ?? currentHash)) {
|
|
799
|
+
if (sameValues) {
|
|
800
|
+
addBypass(opts);
|
|
783
801
|
navigatedSearch = sameLocationSearch;
|
|
802
|
+
} else if (!callerBypasses(opts) && current.name !== UNKNOWN_ROUTE && printsPath(router, routeName, routeParams, routeSearch, current.path)) {
|
|
803
|
+
addBypass(opts);
|
|
804
|
+
return router.navigate(current.name, current.params, current.search, opts);
|
|
784
805
|
}
|
|
785
806
|
}
|
|
786
807
|
}
|