@symbo.ls/router 2.12.53 → 2.12.60
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/index.js +23 -6
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { setCookie } from '@domql/cookie'
|
|
4
4
|
import { redirectBasedOnAuth } from '@symbo.ls/auth-redirect'
|
|
5
|
-
import {
|
|
5
|
+
import { isModalRoute } from '@symbo.ls/platform-utils'
|
|
6
6
|
|
|
7
7
|
const { location } = window
|
|
8
8
|
|
|
@@ -59,9 +59,11 @@ export const router = (
|
|
|
59
59
|
const route = routeArray.join('/').replace('//', '/')
|
|
60
60
|
const routeInContent = `/${routeArray[lastLevel + 1] || ''}`
|
|
61
61
|
|
|
62
|
+
const isPreview = location.pathname.includes('/preview')
|
|
63
|
+
|
|
62
64
|
const content = element.routes[routeInContent] || element.routes['/*']
|
|
63
65
|
|
|
64
|
-
const wasModal =
|
|
66
|
+
const wasModal = isModalRoute(location.pathname.split('#')[0], element)
|
|
65
67
|
const isInitial = options.initialRender
|
|
66
68
|
const hashChanged = hash && hash !== window.location.hash.slice(1)
|
|
67
69
|
const pathChanged = pathname !== lastPathname
|
|
@@ -69,10 +71,12 @@ export const router = (
|
|
|
69
71
|
|
|
70
72
|
if (!content) return
|
|
71
73
|
if (options.pushState) {
|
|
72
|
-
window.history.pushState({
|
|
74
|
+
window.history.pushState({
|
|
75
|
+
prevUrl: window.location.href, ...state
|
|
76
|
+
}, null, route + (hash ? `#${hash}` : ''))
|
|
73
77
|
}
|
|
74
78
|
|
|
75
|
-
const isModal =
|
|
79
|
+
const isModal = isModalRoute(pathname, element)
|
|
76
80
|
|
|
77
81
|
if (pathChanged || !hashChanged) {
|
|
78
82
|
const hasSet = isInitial || (!isInitial && !isModal)
|
|
@@ -80,14 +84,27 @@ export const router = (
|
|
|
80
84
|
// || (!rootRouteHasChanged && { preventUpdateTriggerStateUpdate: true, preventContentUpdate: true })
|
|
81
85
|
|
|
82
86
|
if (options.updateState) {
|
|
83
|
-
element.state.update({
|
|
87
|
+
element.state.update({
|
|
88
|
+
route, hash, routeInContent
|
|
89
|
+
}, {
|
|
90
|
+
preventUpdateTriggerStateUpdate: true,
|
|
91
|
+
preventContentUpdate: true,
|
|
92
|
+
preventUpdate: ['Modal', 'MainHeaderCaptions', 'HeaderSubAside']
|
|
93
|
+
})
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (!isModal && element.Modal) {
|
|
97
|
+
element.Modal.removeContent()
|
|
84
98
|
}
|
|
85
99
|
|
|
86
100
|
if (hasSet) {
|
|
87
101
|
element.set({
|
|
88
102
|
tag: options.useFragment && 'fragment',
|
|
89
103
|
extend: content
|
|
90
|
-
},
|
|
104
|
+
}, {
|
|
105
|
+
// ...(!isInitial && wasModal && !options.forceContentUpdate && { preventContentUpdate: true }),
|
|
106
|
+
preventUpdate: ['MainHeaderCaptions', 'HeaderSubAside']
|
|
107
|
+
})
|
|
91
108
|
}
|
|
92
109
|
}
|
|
93
110
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@symbo.ls/router",
|
|
3
|
-
"version": "2.12.
|
|
3
|
+
"version": "2.12.60",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"scripts": {
|
|
@@ -11,6 +11,6 @@
|
|
|
11
11
|
"@domql/utils": "latest",
|
|
12
12
|
"@symbo.ls/auth-redirect": "latest"
|
|
13
13
|
},
|
|
14
|
-
"gitHead": "
|
|
14
|
+
"gitHead": "fb7db9d1214620c4cd3c107c4d9bd296b7d90f66",
|
|
15
15
|
"source": "index.js"
|
|
16
16
|
}
|