@keenmate/svelte-spa-router 1.0.6 → 1.0.8
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/Router.svelte +25 -24
- package/constants.js +1 -1
- package/package.json +6 -4
package/Router.svelte
CHANGED
|
@@ -40,10 +40,10 @@
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
location = "/" + window.location.pathname.substring(basePath.length).replace(/^\//, "")
|
|
43
|
-
// console.log("SAPA ROUTER Parsing querystring", window.location.search)
|
|
44
43
|
if (window.location.search) {
|
|
45
44
|
querystring = window.location.search.substring(1)
|
|
46
45
|
}
|
|
46
|
+
// console.log("SPA router getting location", window.location, location, querystring)
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
return {location, querystring}
|
|
@@ -54,16 +54,15 @@
|
|
|
54
54
|
*/
|
|
55
55
|
export const loc = readable(
|
|
56
56
|
null,
|
|
57
|
-
|
|
58
|
-
function start(set) {
|
|
57
|
+
set => {
|
|
59
58
|
set(getLocation())
|
|
60
59
|
|
|
61
60
|
const eventName = get(HashRoutingEnabled) ?
|
|
62
61
|
"hashchange" :
|
|
63
62
|
SvelteSPARouterNavigationEvent
|
|
64
63
|
// console.log("Setting loc")
|
|
65
|
-
const update
|
|
66
|
-
console.log("Updating location", getLocation())
|
|
64
|
+
const update = () => {
|
|
65
|
+
// console.log("Updating location", getLocation())
|
|
67
66
|
set(getLocation())
|
|
68
67
|
}
|
|
69
68
|
window.addEventListener(eventName, update, false)
|
|
@@ -167,24 +166,25 @@
|
|
|
167
166
|
else {
|
|
168
167
|
window.dispatchEvent(new Event("hashchange"))
|
|
169
168
|
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
// console.log("get(location)", get(location))
|
|
172
|
+
// if (location_ !== get(location)) {
|
|
173
|
+
if (!location_.startsWith(basePath)) {
|
|
174
|
+
location_ = joinPaths(basePath, location_)
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// console.log(
|
|
178
|
+
// "Before navigate",
|
|
179
|
+
// window.history,
|
|
180
|
+
// doNavigate,
|
|
181
|
+
// newHistoryState,
|
|
182
|
+
// undefined,
|
|
183
|
+
// location_
|
|
184
|
+
// )
|
|
185
|
+
// window.history.pushState(newHistoryState, undefined, location)
|
|
186
|
+
doNavigate(newHistoryState, undefined, location_)
|
|
187
|
+
// }
|
|
188
188
|
|
|
189
189
|
window.dispatchEvent(new Event(SvelteSPARouterNavigationEvent))
|
|
190
190
|
}
|
|
@@ -273,7 +273,8 @@
|
|
|
273
273
|
if (!opts.disabled) {
|
|
274
274
|
scrollstateHistoryHandler(ev.currentTarget.getAttribute("href"))
|
|
275
275
|
}
|
|
276
|
-
}
|
|
276
|
+
}
|
|
277
|
+
else {
|
|
277
278
|
// console.log("Handling link click event")
|
|
278
279
|
const linkTarget = ev.target.getAttribute("target")
|
|
279
280
|
if (linkTarget && linkTarget !== "_self") {
|
package/constants.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SvelteSPARouterNavigationEvent =
|
|
1
|
+
export const SvelteSPARouterNavigationEvent = "popstate"
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@keenmate/svelte-spa-router",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.8",
|
|
5
5
|
"description": "Router for SPAs using Svelte 4",
|
|
6
6
|
"main": "Router.svelte",
|
|
7
7
|
"svelte": "Router.svelte",
|
|
@@ -44,12 +44,14 @@
|
|
|
44
44
|
"spa"
|
|
45
45
|
],
|
|
46
46
|
"author": "Alessandro Segala (@ItalyPaleAle)",
|
|
47
|
+
"contributors": [
|
|
48
|
+
"Filip Jakab (@FilipJakab)"
|
|
49
|
+
],
|
|
47
50
|
"license": "MIT",
|
|
48
|
-
"funding": "https://github.com/sponsors/ItalyPaleAle",
|
|
49
51
|
"bugs": {
|
|
50
|
-
"url": "https://github.com/
|
|
52
|
+
"url": "https://github.com/KeenMate/svelte-spa-router/issues"
|
|
51
53
|
},
|
|
52
|
-
"homepage": "https://github.com/
|
|
54
|
+
"homepage": "https://github.com/KeenMate/svelte-spa-router#readme",
|
|
53
55
|
"dependencies": {
|
|
54
56
|
"regexparam": "2.0.2"
|
|
55
57
|
},
|