@symbo.ls/router 3.1.1 → 3.2.3
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 +14 -8
- package/package.json +3 -3
package/index.js
CHANGED
|
@@ -57,6 +57,15 @@ export async function router (path = '/', el, state = {}, passedOptions = {}) {
|
|
|
57
57
|
const options = merge(passedOptions, defaultOptions)
|
|
58
58
|
lastLevel = options.level
|
|
59
59
|
|
|
60
|
+
const isModal = element.getRootState('activeModal')
|
|
61
|
+
if (isModal) {
|
|
62
|
+
if (options.event) {
|
|
63
|
+
options.event.preventDefault()
|
|
64
|
+
options.event.stopPropagation()
|
|
65
|
+
}
|
|
66
|
+
return element.call('closeModal')
|
|
67
|
+
}
|
|
68
|
+
|
|
60
69
|
const urlObj = new options.window.URL(options.window.location.origin + path)
|
|
61
70
|
const { pathname, search, hash } = urlObj
|
|
62
71
|
|
|
@@ -74,9 +83,9 @@ export async function router (path = '/', el, state = {}, passedOptions = {}) {
|
|
|
74
83
|
const routeInContent = `/${routeArray[lastLevel + 1] || ''}`
|
|
75
84
|
|
|
76
85
|
// const isPreview = location.pathname.includes('/editor')
|
|
77
|
-
|
|
78
|
-
const
|
|
79
|
-
const content =
|
|
86
|
+
// const pages = element.routes || element.context.pages
|
|
87
|
+
// const content = pages[routeInContent] || pages['/*']
|
|
88
|
+
const content = element.routes[routeInContent] || element.routes['/*']
|
|
80
89
|
|
|
81
90
|
const wasModal = element.call(
|
|
82
91
|
'isModalRoute',
|
|
@@ -93,7 +102,7 @@ export async function router (path = '/', el, state = {}, passedOptions = {}) {
|
|
|
93
102
|
) {
|
|
94
103
|
return
|
|
95
104
|
}
|
|
96
|
-
if (options.pushState) {
|
|
105
|
+
if (options.pushState && options.level === 0) {
|
|
97
106
|
options.window.history.pushState(
|
|
98
107
|
{
|
|
99
108
|
prevUrl: options.window.location.href,
|
|
@@ -104,8 +113,6 @@ export async function router (path = '/', el, state = {}, passedOptions = {}) {
|
|
|
104
113
|
)
|
|
105
114
|
}
|
|
106
115
|
|
|
107
|
-
const isModal = Boolean(element.call('isModalRoute', pathname))
|
|
108
|
-
|
|
109
116
|
if (pathChanged || !hashChanged) {
|
|
110
117
|
// || (!rootRouteHasChanged && { preventUpdateTriggerStateUpdate: true, preventContentUpdate: true })
|
|
111
118
|
|
|
@@ -115,13 +122,12 @@ export async function router (path = '/', el, state = {}, passedOptions = {}) {
|
|
|
115
122
|
{
|
|
116
123
|
preventUpdate: [options.preventUpdate, 'content'],
|
|
117
124
|
updateByRouter: true,
|
|
118
|
-
onlyUpdate: isModal && 'Modal',
|
|
119
125
|
...options.updateStateOptions
|
|
120
126
|
}
|
|
121
127
|
)
|
|
122
128
|
}
|
|
123
129
|
|
|
124
|
-
const hasSet = isInitial ||
|
|
130
|
+
const hasSet = isInitial || !isInitial
|
|
125
131
|
if (hasSet) {
|
|
126
132
|
if (options.forceContentUpdate || (!isInitial && wasModal)) {
|
|
127
133
|
await element.content.update(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@symbo.ls/router",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.3",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
"vpatch": "npm version patch && npm publish --access public"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@domql/utils": "^3.
|
|
11
|
+
"@domql/utils": "^3.2.3"
|
|
12
12
|
},
|
|
13
|
-
"gitHead": "
|
|
13
|
+
"gitHead": "9fc1b79b41cdc725ca6b24aec64920a599634681",
|
|
14
14
|
"source": "index.js"
|
|
15
15
|
}
|