@domql/router 2.5.34 → 2.5.49
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 +6 -2
- package/index.js +6 -2
- package/package.json +2 -2
package/dist/cjs/index.js
CHANGED
|
@@ -48,8 +48,9 @@ const defaultOptions = {
|
|
|
48
48
|
scrollToOptions: { behavior: "smooth" }
|
|
49
49
|
};
|
|
50
50
|
const router = (path, element, state = {}, passedOptions = {}) => {
|
|
51
|
-
const options = { ...defaultOptions, ...passedOptions };
|
|
51
|
+
const options = { ...defaultOptions, ...element.context.routerOptions, ...passedOptions };
|
|
52
52
|
lastLevel = options.lastLevel;
|
|
53
|
+
const newElementKey = options.newElementKey;
|
|
53
54
|
const [pathname, hash] = path.split("#");
|
|
54
55
|
const rootNode = element.node;
|
|
55
56
|
const route = getActiveRoute(options.level, pathname);
|
|
@@ -67,10 +68,13 @@ const router = (path, element, state = {}, passedOptions = {}) => {
|
|
|
67
68
|
if (options.updateState) {
|
|
68
69
|
element.state.update({ route, hash }, { preventContentUpdate: true });
|
|
69
70
|
}
|
|
71
|
+
if (newElementKey && options.removeOldElement) {
|
|
72
|
+
element[newElementKey].remove();
|
|
73
|
+
}
|
|
70
74
|
element.set({
|
|
71
75
|
tag: options.useFragment && "fragment",
|
|
72
76
|
extend: content
|
|
73
|
-
});
|
|
77
|
+
}, { newElementKey });
|
|
74
78
|
}
|
|
75
79
|
if (options.scrollToTop) {
|
|
76
80
|
scrollNode.scrollTo({
|
package/index.js
CHANGED
|
@@ -31,8 +31,9 @@ export const router = (
|
|
|
31
31
|
state = {},
|
|
32
32
|
passedOptions = {}
|
|
33
33
|
) => {
|
|
34
|
-
const options = { ...defaultOptions, ...passedOptions }
|
|
34
|
+
const options = { ...defaultOptions, ...element.context.routerOptions, ...passedOptions }
|
|
35
35
|
lastLevel = options.lastLevel
|
|
36
|
+
const newElementKey = options.newElementKey
|
|
36
37
|
|
|
37
38
|
const [pathname, hash] = path.split('#')
|
|
38
39
|
|
|
@@ -54,10 +55,13 @@ export const router = (
|
|
|
54
55
|
element.state.update({ route, hash }, { preventContentUpdate: true })
|
|
55
56
|
}
|
|
56
57
|
|
|
58
|
+
if (newElementKey && options.removeOldElement) {
|
|
59
|
+
element[newElementKey].remove()
|
|
60
|
+
}
|
|
57
61
|
element.set({
|
|
58
62
|
tag: options.useFragment && 'fragment',
|
|
59
63
|
extend: content
|
|
60
|
-
})
|
|
64
|
+
}, { newElementKey })
|
|
61
65
|
}
|
|
62
66
|
|
|
63
67
|
if (options.scrollToTop) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@domql/router",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.49",
|
|
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": "c533b0747885c056fbcb50565c74b6125ecba7e9",
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@babel/core": "^7.12.0"
|
|
31
31
|
}
|