@symbo.ls/router 2.12.113 → 2.12.122

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 (3) hide show
  1. package/index.js +16 -10
  2. package/location.js +1 -5
  3. package/package.json +3 -4
package/index.js CHANGED
@@ -1,5 +1,3 @@
1
- 'use strict'
2
-
3
1
  import * as utils from '@domql/utils'
4
2
  const { setCookie, merge } = utils.default || utils
5
3
 
@@ -11,7 +9,9 @@ export const getLocationPath = (
11
9
  ) => {
12
10
  const routeArray = route.split('/')
13
11
  const activeRoute = routeArray[index + 1]
14
- if (activeRoute) return `/${activeRoute}`
12
+ if (activeRoute) {
13
+ return `/${activeRoute}`
14
+ }
15
15
  }
16
16
 
17
17
  export const getLastLocationPath = (
@@ -20,10 +20,12 @@ export const getLastLocationPath = (
20
20
  ) => {
21
21
  const routeArray = route.split('/')
22
22
  const activeRoute = routeArray[routeArray.length - level - 1]
23
- if (activeRoute) return `/${activeRoute}`
23
+ if (activeRoute) {
24
+ return `/${activeRoute}`
25
+ }
24
26
  }
25
27
 
26
- export let lastPathname
28
+ export let lastPathname = null
27
29
  export let lastLevel = 0
28
30
 
29
31
  const defaultOptions = {
@@ -49,6 +51,7 @@ const defaultOptions = {
49
51
  scrollToOptions: { behavior: 'smooth' }
50
52
  }
51
53
 
54
+ // eslint-disable-next-line default-param-last
52
55
  export function router (path = '/', el, state = {}, passedOptions = {}) {
53
56
  const element = el || (this && this.getRoot())
54
57
  const options = merge(passedOptions, defaultOptions)
@@ -85,7 +88,7 @@ export function router (path = '/', el, state = {}, passedOptions = {}) {
85
88
 
86
89
  if (
87
90
  !content ||
88
- (element.state.root.debugging && !options.allowRouterWhileInspect)
91
+ (element.getRootState('debugging') && !options.allowRouterWhileInspect)
89
92
  ) {
90
93
  return
91
94
  }
@@ -100,10 +103,9 @@ export function router (path = '/', el, state = {}, passedOptions = {}) {
100
103
  )
101
104
  }
102
105
 
103
- const isModal = !!element.call('isModalRoute', pathname)
106
+ const isModal = Boolean(element.call('isModalRoute', pathname))
104
107
 
105
108
  if (pathChanged || !hashChanged) {
106
- // const rootRouteHasChanged = rootRoute !== element.state.rootRoute
107
109
  // || (!rootRouteHasChanged && { preventUpdateTriggerStateUpdate: true, preventContentUpdate: true })
108
110
 
109
111
  if (options.updateState) {
@@ -140,7 +142,9 @@ export function router (path = '/', el, state = {}, passedOptions = {}) {
140
142
  }
141
143
  )
142
144
  }
143
- if (element.content) element.content.__ref.__componentKey = route
145
+ if (element.content) {
146
+ element.content.__ref.__componentKey = route
147
+ }
144
148
  }
145
149
  }
146
150
 
@@ -178,5 +182,7 @@ export function router (path = '/', el, state = {}, passedOptions = {}) {
178
182
  }
179
183
  }
180
184
 
181
- if (route !== '/*') setCookie('route', route)
185
+ if (route !== '/*') {
186
+ setCookie('route', route)
187
+ }
182
188
  }
package/location.js CHANGED
@@ -1,7 +1,3 @@
1
- 'use strict'
2
-
3
1
  export const onLeave = msg => {
4
- window.onbeforeunload = function () {
5
- return msg || 'Are you sure you want to leave?'
6
- }
2
+ window.onbeforeunload = () => msg || 'Are you sure you want to leave?'
7
3
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@symbo.ls/router",
3
- "version": "2.12.113",
3
+ "version": "2.12.122",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -9,9 +9,8 @@
9
9
  },
10
10
  "dependencies": {
11
11
  "@domql/cookie": "latest",
12
- "@domql/utils": "latest",
13
- "@symbo.ls/auth-redirect": "latest"
12
+ "@domql/utils": "latest"
14
13
  },
15
- "gitHead": "80b9cba1ca65e6636085e7c58dbeb062f923fdd7",
14
+ "gitHead": "7c52a345b503b9be2c8770d2c9b68c620bbba4d1",
16
15
  "source": "index.js"
17
16
  }