honox 0.1.2 → 0.1.3

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.
@@ -1,5 +1,15 @@
1
1
  import { Suspense, use } from "hono/jsx/dom";
2
2
  const buildCreateChildrenFn = (createElement) => {
3
+ const createElementFromHTMLElement = async (element) => {
4
+ const props = {
5
+ children: await createChildren(element.childNodes)
6
+ };
7
+ const attributes = element.attributes;
8
+ for (let i = 0; i < attributes.length; i++) {
9
+ props[attributes[i].name] = attributes[i].value;
10
+ }
11
+ return createElement(element.nodeName, props);
12
+ };
3
13
  const createChildren = async (childNodes) => {
4
14
  const children = [];
5
15
  for (let i = 0; i < childNodes.length; i++) {
@@ -32,11 +42,7 @@ const buildCreateChildrenFn = (createElement) => {
32
42
  } else if (child2.nodeType === 3) {
33
43
  fallback.push(child2.textContent);
34
44
  } else {
35
- fallback.push(
36
- await createElement(child2.nodeName, {
37
- children: await createChildren(child2.childNodes)
38
- })
39
- );
45
+ fallback.push(await createElementFromHTMLElement(child2));
40
46
  }
41
47
  }
42
48
  const fallbackTemplates = document.querySelectorAll(
@@ -65,11 +71,7 @@ const buildCreateChildrenFn = (createElement) => {
65
71
  })
66
72
  );
67
73
  } else {
68
- children.push(
69
- await createElement(child.nodeName, {
70
- children: await createChildren(child.childNodes)
71
- })
72
- );
74
+ children.push(await createElementFromHTMLElement(child));
73
75
  }
74
76
  }
75
77
  return children;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "honox",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "main": "dist/index.js",
5
5
  "type": "module",
6
6
  "scripts": {