@symbo.ls/router 2.28.49 → 2.28.50

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.
Files changed (2) hide show
  1. package/index.js +11 -5
  2. 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
 
@@ -92,7 +101,7 @@ export async function router (path = '/', el, state = {}, passedOptions = {}) {
92
101
  ) {
93
102
  return
94
103
  }
95
- if (options.pushState) {
104
+ if (options.pushState && options.level === 0) {
96
105
  options.window.history.pushState(
97
106
  {
98
107
  prevUrl: options.window.location.href,
@@ -103,8 +112,6 @@ export async function router (path = '/', el, state = {}, passedOptions = {}) {
103
112
  )
104
113
  }
105
114
 
106
- const isModal = Boolean(element.call('isModalRoute', pathname))
107
-
108
115
  if (pathChanged || !hashChanged) {
109
116
  // || (!rootRouteHasChanged && { preventUpdateTriggerStateUpdate: true, preventContentUpdate: true })
110
117
 
@@ -114,13 +121,12 @@ export async function router (path = '/', el, state = {}, passedOptions = {}) {
114
121
  {
115
122
  preventUpdate: [options.preventUpdate, 'content'],
116
123
  updateByRouter: true,
117
- onlyUpdate: isModal && 'Modal',
118
124
  ...options.updateStateOptions
119
125
  }
120
126
  )
121
127
  }
122
128
 
123
- const hasSet = isInitial || (!isInitial && !isModal)
129
+ const hasSet = isInitial || !isInitial
124
130
  if (hasSet) {
125
131
  if (options.forceContentUpdate || (!isInitial && wasModal)) {
126
132
  await element.content.update(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@symbo.ls/router",
3
- "version": "2.28.49",
3
+ "version": "2.28.50",
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": "^2.28.49"
11
+ "@domql/utils": "^2.28.50"
12
12
  },
13
- "gitHead": "c30cac084c3a84a5fe936f9215b91b87b77378f5",
13
+ "gitHead": "1118b1967af5775fd23520e21e543c4530b97864",
14
14
  "source": "index.js"
15
15
  }