@zyrab/domo 1.0.2 → 1.0.4

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zyrab/domo",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "Minimalist DOM builder and chaining-friendly micro-framework with router support.",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -13,7 +13,7 @@
13
13
  ],
14
14
  "repository": {
15
15
  "type": "git",
16
- "url": "https://github.com/zyrab/domo.git"
16
+ "url": "git+https://github.com/zyrab/domo.git"
17
17
  },
18
18
  "keywords": [
19
19
  "dom",
@@ -3,8 +3,7 @@ let _listeners = [];
3
3
  const _scrollPositions = {};
4
4
  let _previousUrl = "";
5
5
 
6
- let _root = document.createElement("main");
7
- _root.id = "main";
6
+ let _root;
8
7
 
9
8
  function init() {
10
9
  ["DOMContentLoaded", "popstate"].forEach((event) =>
@@ -40,7 +39,7 @@ async function render({ component, meta }, params) {
40
39
  }
41
40
  } catch (error) {
42
41
  console.error("Rendering error:", error);
43
- const fallback = _routes["*"]?.component?.({ error: err.message });
42
+ const fallback = _routes["*"]?.component?.({ error: error.message });
44
43
  if (fallback) {
45
44
  _root.replaceChildren();
46
45
  _root.appendChild(fallback);
@@ -130,7 +129,11 @@ const Router = {
130
129
  * Mount point of the router, where components will be rendered.
131
130
  * @returns {HTMLElement} The root DOM element used by the router.
132
131
  */
133
- mount: () => _root,
132
+ mount: () => {
133
+ _root = document.createElement("main");
134
+ _root.id = "main";
135
+ return _root;
136
+ },
134
137
 
135
138
  /**
136
139
  * Initializes the router by setting up event listeners and loading the initial route.