@primate/core 0.9.18 → 0.9.19
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/lib/private/client/navigate.js +18 -15
- package/package.json +1 -1
|
@@ -46,23 +46,26 @@ async function goto(target, state = false, after) {
|
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
async function go(href, event) {
|
|
49
|
-
const url = new URL(href);
|
|
50
|
-
const { hash, pathname } = url;
|
|
51
49
|
const { location } = globalThis;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
storage.new({ hash: location.hash, pathname: location.pathname, scrollTop, stop: true });
|
|
63
|
-
history.pushState(null, "", `${location.pathname}${hash}`);
|
|
50
|
+
const url = new URL(href, location.href);
|
|
51
|
+
const { hash, pathname, search } = url;
|
|
52
|
+
if (url.origin !== location.origin) {
|
|
53
|
+
if (event === undefined)
|
|
54
|
+
location.assign(url.toString());
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
event?.preventDefault();
|
|
58
|
+
if (location.pathname !== pathname || location.search !== search) {
|
|
59
|
+
await goto(url, true, () => {
|
|
64
60
|
scroll_hash(hash);
|
|
65
|
-
|
|
61
|
+
globalThis.dispatchEvent(new Event("updated"));
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
if (location.hash !== hash) {
|
|
65
|
+
const { scrollTop } = globalThis.document.scrollingElement;
|
|
66
|
+
storage.new({ hash: location.hash, pathname: location.pathname, scrollTop, stop: true });
|
|
67
|
+
history.pushState(null, "", `${location.pathname}${location.search}${hash}`);
|
|
68
|
+
scroll_hash(hash);
|
|
66
69
|
}
|
|
67
70
|
}
|
|
68
71
|
const navigate = {
|