@symbo.ls/router 2.34.35 → 3.1.2

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 +9 -20
  2. package/package.json +3 -3
package/index.js CHANGED
@@ -51,12 +51,9 @@ const defaultOptions = {
51
51
  scrollToOptions: { behavior: 'smooth' }
52
52
  }
53
53
 
54
- const lastElement = {}
55
-
56
54
  // eslint-disable-next-line default-param-last
57
- export async function router(path = '/', el, state = {}, passedOptions = {}) {
58
- const rootElem = this && this.getRoot()
59
- const element = el && el.routes ? el : rootElem
55
+ export async function router (path = '/', el, state = {}, passedOptions = {}) {
56
+ const element = el || (this && this.getRoot())
60
57
  const options = merge(passedOptions, defaultOptions)
61
58
  lastLevel = options.level
62
59
 
@@ -66,8 +63,7 @@ export async function router(path = '/', el, state = {}, passedOptions = {}) {
66
63
  options.event.preventDefault()
67
64
  options.event.stopPropagation()
68
65
  }
69
- element.call('closeModal')
70
- if (options.event) {options.event.preventDefault()}
66
+ return element.call('closeModal')
71
67
  }
72
68
 
73
69
  const urlObj = new options.window.URL(options.window.location.origin + path)
@@ -86,6 +82,9 @@ export async function router(path = '/', el, state = {}, passedOptions = {}) {
86
82
  const route = routeArray.join('/').replace('//', '/')
87
83
  const routeInContent = `/${routeArray[lastLevel + 1] || ''}`
88
84
 
85
+ // const isPreview = location.pathname.includes('/editor')
86
+ // const pages = element.routes || element.context.pages
87
+ // const content = pages[routeInContent] || pages['/*']
89
88
  const content = element.routes[routeInContent] || element.routes['/*']
90
89
 
91
90
  const wasModal = element.call(
@@ -116,14 +115,12 @@ export async function router(path = '/', el, state = {}, passedOptions = {}) {
116
115
 
117
116
  if (pathChanged || !hashChanged) {
118
117
  // || (!rootRouteHasChanged && { preventUpdateTriggerStateUpdate: true, preventContentUpdate: true })
119
- // console.log('ROUTER SETTING')
120
118
 
121
119
  if (options.updateState) {
122
120
  await element.state.update(
123
121
  { route, hash, routeInContent, debugging: false },
124
122
  {
125
123
  preventUpdate: [options.preventUpdate, 'content'],
126
- // preventContentUpdate: true, // prevent only platform.content
127
124
  updateByRouter: true,
128
125
  ...options.updateStateOptions
129
126
  }
@@ -132,30 +129,22 @@ export async function router(path = '/', el, state = {}, passedOptions = {}) {
132
129
 
133
130
  const hasSet = isInitial || !isInitial
134
131
  if (hasSet) {
135
- if (
136
- element.content &&
137
- (options.forceContentUpdate || (!isInitial && wasModal))
138
- ) {
139
- await element.content?.update(
132
+ if (options.forceContentUpdate || (!isInitial && wasModal)) {
133
+ await element.content.update(
140
134
  {},
141
135
  {
142
136
  preventUpdate: options.preventUpdate
143
137
  }
144
138
  )
145
139
  } else {
146
- lastElement.content = content
147
- element.removeContent()
148
140
  await element.set(
149
141
  {
150
142
  tag: options.useFragment && 'fragment',
151
- extend: content
143
+ extends: content
152
144
  },
153
145
  {
154
146
  // ...(!isInitial && wasModal && !options.forceContentUpdate && { preventContentUpdate: true }),
155
- lastElement,
156
- routerContentElement: content,
157
147
  preventUpdate: options.preventUpdate,
158
-
159
148
  ...options.setOptions
160
149
  }
161
150
  )
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@symbo.ls/router",
3
- "version": "2.34.35",
3
+ "version": "3.1.2",
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.34.35"
11
+ "@domql/utils": "^3.1.2"
12
12
  },
13
- "gitHead": "0be12bcdd99c265fdeded6d756a1a3616a943ffc",
13
+ "gitHead": "429b36616aa04c8587a26ce3c129815115e35897",
14
14
  "source": "index.js"
15
15
  }