domql 1.5.130 → 1.5.132

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/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "domql",
3
3
  "description": "DOM rendering Javascript framework at early stage.",
4
4
  "author": "symbo.ls",
5
- "version": "1.5.130",
5
+ "version": "1.5.132",
6
6
  "repository": "https://github.com/domql/domql",
7
7
  "publishConfig": {
8
8
  "registry": "https://registry.npmjs.org"
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var router_exports = {};
20
+ __export(router_exports, {
21
+ getActiveRoute: () => getActiveRoute,
22
+ lastLevel: () => lastLevel,
23
+ router: () => router
24
+ });
25
+ module.exports = __toCommonJS(router_exports);
26
+ var import_globals = require("@domql/globals");
27
+ var import_utils = require("@domql/utils");
28
+ const getActiveRoute = (route = import_globals.window.location.pathname, level) => `/${route.split("/")[level + 1]}`;
29
+ let lastLevel = 0;
30
+ const defaultOptions = {
31
+ level: lastLevel,
32
+ pushState: true,
33
+ scrollToTop: true,
34
+ scrollToNode: false,
35
+ scrollDocument: false,
36
+ useFragment: false,
37
+ updateState: true,
38
+ scrollToOffset: 0,
39
+ scrollToOptions: { behavior: "smooth" }
40
+ };
41
+ const router = (element, path, state = {}, options = defaultOptions) => {
42
+ (0, import_utils.merge)(options, defaultOptions);
43
+ lastLevel = options.lastLevel;
44
+ const [pathname, hash] = path.split("#");
45
+ const route = getActiveRoute(pathname, options.level);
46
+ const content = element.routes[route] || element.routes["/*"];
47
+ if (content) {
48
+ if (options.pushState)
49
+ import_globals.window.history.pushState(state, null, pathname + (hash ? `#${hash}` : ""));
50
+ element.set({ tag: options.useFragment && "fragment", extend: content });
51
+ if (options.updateState)
52
+ element.state.update({ route, hash }, { preventContentUpdate: !options.stateContentUpdate });
53
+ const rootNode = element.node;
54
+ const scrollNode = options.scrollDocument ? document.documentElement : rootNode;
55
+ if (options.scrollToTop) {
56
+ scrollNode.scrollTo({
57
+ ...options.scrollToOptions || {},
58
+ top: 0,
59
+ left: 0
60
+ });
61
+ }
62
+ if (options.scrollToNode) {
63
+ content.content.node.scrollTo({
64
+ ...options.scrollToOptions || {},
65
+ top: 0,
66
+ left: 0
67
+ });
68
+ }
69
+ if (hash) {
70
+ const activeNode = document.getElementById(hash);
71
+ if (activeNode) {
72
+ const top = activeNode.getBoundingClientRect().top + rootNode.scrollTop - options.scrollToOffset || 0;
73
+ scrollNode.scrollTo({
74
+ ...options.scrollToOptions || {},
75
+ top,
76
+ left: 0
77
+ });
78
+ }
79
+ }
80
+ }
81
+ };
@@ -0,0 +1,4 @@
1
+ {
2
+ "type": "commonjs",
3
+ "main": "index.js"
4
+ }
@@ -23,9 +23,7 @@ export const applyEvents = element => {
23
23
 
24
24
  const appliedFunction = element.on[param]
25
25
  if (isFunction(appliedFunction)) {
26
- node.addEventListener(param, event =>
27
- appliedFunction(event, element, element.state, element.context),
28
- true)
26
+ node.addEventListener(param, event => appliedFunction(event, element, element.state, element.context))
29
27
  }
30
28
  }
31
29
  }
@@ -39,7 +39,7 @@ export const createNode = (element, options) => {
39
39
 
40
40
  // node.dataset // .key = element.key
41
41
 
42
- if (ENV === 'test' || ENV === 'development') {
42
+ if (ENV === 'test' || ENV === 'development' || options.alowRefReference) {
43
43
  node.ref = element
44
44
  if (isFunction(node.setAttribute)) node.setAttribute('key', element.key)
45
45
  }