@domql/router 2.4.0 → 2.4.7

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/dist/cjs/index.js CHANGED
@@ -25,8 +25,8 @@ __export(router_exports, {
25
25
  router: () => router
26
26
  });
27
27
  module.exports = __toCommonJS(router_exports);
28
- var import_globals = require("@domql/globals");
29
- const getActiveRoute = (level = 0, route = import_globals.window.location.pathname) => {
28
+ var import_utils = require("@domql/utils");
29
+ const getActiveRoute = (level = 0, route = import_utils.window.location.pathname) => {
30
30
  const routeArray = route.split("/");
31
31
  const activeRoute = routeArray[level + 1];
32
32
  if (activeRoute)
@@ -40,7 +40,7 @@ const defaultOptions = {
40
40
  initialRender: false,
41
41
  scrollToTop: true,
42
42
  scrollToNode: false,
43
- scrollNode: import_globals.document && import_globals.document.documentElement,
43
+ scrollNode: import_utils.document && import_utils.document.documentElement,
44
44
  scrollBody: false,
45
45
  useFragment: false,
46
46
  updateState: true,
@@ -55,13 +55,13 @@ const router = (path, element, state = {}, passedOptions = {}) => {
55
55
  const route = getActiveRoute(options.level, pathname);
56
56
  const content = element.routes[route || "/"] || element.routes["/*"];
57
57
  const scrollNode = options.scrollToNode ? rootNode : options.scrollNode;
58
- const hashChanged = hash && hash !== import_globals.window.location.hash.slice(1);
58
+ const hashChanged = hash && hash !== import_utils.window.location.hash.slice(1);
59
59
  const pathChanged = pathname !== lastPathname;
60
60
  lastPathname = pathname;
61
61
  if (!content)
62
62
  return;
63
63
  if (options.pushState) {
64
- import_globals.window.history.pushState(state, null, pathname + (hash ? `#${hash}` : ""));
64
+ import_utils.window.history.pushState(state, null, pathname + (hash ? `#${hash}` : ""));
65
65
  }
66
66
  if (pathChanged || !hashChanged) {
67
67
  if (options.updateState) {
@@ -87,7 +87,7 @@ const router = (path, element, state = {}, passedOptions = {}) => {
87
87
  });
88
88
  }
89
89
  if (hash) {
90
- const activeNode = import_globals.document.getElementById(hash);
90
+ const activeNode = import_utils.document.getElementById(hash);
91
91
  if (activeNode) {
92
92
  const top = activeNode.getBoundingClientRect().top + rootNode.scrollTop - options.scrollToOffset || 0;
93
93
  scrollNode.scrollTo({
package/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict'
2
2
 
3
- import { document, window } from '@domql/globals'
3
+ import { document, window } from '@domql/utils'
4
4
 
5
5
  export const getActiveRoute = (level = 0, route = window.location.pathname) => {
6
6
  const routeArray = route.split('/')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@domql/router",
3
- "version": "2.4.0",
3
+ "version": "2.4.7",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "module": "dist/esm/index.js",
@@ -25,7 +25,7 @@
25
25
  "@domql/globals": "latest",
26
26
  "@domql/utils": "latest"
27
27
  },
28
- "gitHead": "d01a7237a0065a5a439a03062064076c5fdc91b7",
28
+ "gitHead": "fd9683a7d42893983463967fa512ac095a6a36e9",
29
29
  "devDependencies": {
30
30
  "@babel/core": "^7.12.0"
31
31
  }