@symbo.ls/router 2.11.29 → 2.11.32

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 +8 -2
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -10,6 +10,7 @@ export const getActiveRoute = (level = 0, route = window.location.pathname) => {
10
10
  if (activeRoute) return `/${activeRoute}`
11
11
  }
12
12
 
13
+ export let lastPathname
13
14
  export let lastLevel = 0
14
15
 
15
16
  const defaultOptions = {
@@ -51,12 +52,17 @@ export const router = (
51
52
 
52
53
  const isModal = (findModal(element, element.state) || {}).FoundModal
53
54
  const isInitial = options.initialRender
55
+ const hashChanged = hash && hash !== window.location.hash.slice(1)
56
+ const pathChanged = pathname !== lastPathname
57
+ lastPathname = pathname
54
58
 
55
59
  if (content) {
56
60
  if (options.pushState) window.history.pushState(state, null, route + (hash ? `#${hash}` : ''))
57
61
 
58
- if (isInitial || (!isInitial && !isModal)) element.set({ tag: options.useFragment && 'fragment', extend: content })
59
- if (options.updateState) element.state.update({ route, hash })
62
+ if (pathChanged || !hashChanged) {
63
+ if (isInitial || (!isInitial && !isModal)) element.set({ tag: options.useFragment && 'fragment', extend: content })
64
+ if (options.updateState) element.state.update({ route, hash })
65
+ }
60
66
 
61
67
  const rootNode = element.node
62
68
  const scrollNode = options.scrollDocument ? document.documentElement : rootNode
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@symbo.ls/router",
3
- "version": "2.11.29",
3
+ "version": "2.11.32",
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": "8487231f7e47b8d7789658c3ac6e284f7bceca5e",
14
+ "gitHead": "747be57b5b769257c72f48dc611e1376af08d312",
15
15
  "source": "index.js"
16
16
  }