@domql/router 2.3.117 → 2.3.131
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 +4 -2
- package/index.js +6 -4
- package/package.json +2 -2
package/dist/cjs/index.js
CHANGED
|
@@ -26,6 +26,7 @@ __export(router_exports, {
|
|
|
26
26
|
module.exports = __toCommonJS(router_exports);
|
|
27
27
|
var import_globals = require("@domql/globals");
|
|
28
28
|
var import_utils = require("@domql/utils");
|
|
29
|
+
var _a;
|
|
29
30
|
const getActiveRoute = (route = import_globals.window.location.pathname, level) => `/${route.split("/")[level + 1]}`;
|
|
30
31
|
let lastLevel = 0;
|
|
31
32
|
const defaultOptions = {
|
|
@@ -33,7 +34,7 @@ const defaultOptions = {
|
|
|
33
34
|
pushState: true,
|
|
34
35
|
scrollToTop: true,
|
|
35
36
|
scrollToNode: false,
|
|
36
|
-
scrollNode: import_globals.document.documentElement,
|
|
37
|
+
scrollNode: (_a = import_globals.document) == null ? void 0 : _a.documentElement,
|
|
37
38
|
scrollBody: false,
|
|
38
39
|
scrollDocument: true,
|
|
39
40
|
useFragment: false,
|
|
@@ -52,10 +53,11 @@ const router = (path, element, state = {}, options = defaultOptions) => {
|
|
|
52
53
|
if (options.pushState)
|
|
53
54
|
import_globals.window.history.pushState(state, null, pathname + (hash ? `#${hash}` : ""));
|
|
54
55
|
element.set({ tag: options.useFragment && "fragment", extend: content });
|
|
55
|
-
if (options.updateState)
|
|
56
|
+
if (options.updateState) {
|
|
56
57
|
element.state.update({ route, hash }, {
|
|
57
58
|
preventContentUpdate: !options.stateContentUpdate
|
|
58
59
|
});
|
|
60
|
+
}
|
|
59
61
|
const rootNode = element.node;
|
|
60
62
|
const scrollNode = options.scrollNode;
|
|
61
63
|
if (options.scrollToTop) {
|
package/index.js
CHANGED
|
@@ -14,7 +14,7 @@ const defaultOptions = {
|
|
|
14
14
|
pushState: true,
|
|
15
15
|
scrollToTop: true,
|
|
16
16
|
scrollToNode: false,
|
|
17
|
-
scrollNode: document
|
|
17
|
+
scrollNode: document?.documentElement,
|
|
18
18
|
scrollBody: false,
|
|
19
19
|
scrollDocument: true,
|
|
20
20
|
useFragment: false,
|
|
@@ -41,9 +41,11 @@ export const router = (
|
|
|
41
41
|
if (options.pushState) window.history.pushState(state, null, pathname + (hash ? `#${hash}` : ''))
|
|
42
42
|
|
|
43
43
|
element.set({ tag: options.useFragment && 'fragment', extend: content })
|
|
44
|
-
if (options.updateState)
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
if (options.updateState) {
|
|
45
|
+
element.state.update({ route, hash }, {
|
|
46
|
+
preventContentUpdate: !options.stateContentUpdate
|
|
47
|
+
})
|
|
48
|
+
}
|
|
47
49
|
|
|
48
50
|
const rootNode = element.node
|
|
49
51
|
const scrollNode = options.scrollNode
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@domql/router",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.131",
|
|
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": "
|
|
28
|
+
"gitHead": "9693b45324f8fcd2524259e02888180801d7de1f",
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@babel/core": "^7.12.0"
|
|
31
31
|
}
|