@thi.ng/hiccup 5.3.40 → 5.4.0

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.
Files changed (2) hide show
  1. package/package.json +7 -7
  2. package/serialize.js +11 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/hiccup",
3
- "version": "5.3.40",
3
+ "version": "5.4.0",
4
4
  "description": "HTML/SVG/XML serialization of nested data structures, iterables & closures",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -35,18 +35,18 @@
35
35
  "clean": "bun ../../tools/src/clean-package.ts",
36
36
  "doc": "typedoc --options ../../typedoc.json --out doc src/index.ts",
37
37
  "doc:readme": "bun ../../tools/src/module-stats.ts && bun ../../tools/src/readme.ts",
38
+ "format": "../../node_modules/.bin/prettier src test --write",
38
39
  "pub": "npm publish --access public",
39
40
  "test": "bun test",
40
41
  "tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
41
42
  },
42
43
  "dependencies": {
43
- "@thi.ng/api": "^8.12.16",
44
- "@thi.ng/checks": "^3.8.6",
45
- "@thi.ng/errors": "^2.6.5",
46
- "@thi.ng/strings": "^3.10.0"
44
+ "@thi.ng/api": "^8.12.17",
45
+ "@thi.ng/checks": "^3.8.7",
46
+ "@thi.ng/errors": "^2.6.6",
47
+ "@thi.ng/strings": "^3.10.1"
47
48
  },
48
49
  "devDependencies": {
49
- "@thi.ng/atom": "^5.3.57",
50
50
  "esbuild": "^0.27.2",
51
51
  "typedoc": "^0.28.16",
52
52
  "typescript": "^5.9.3"
@@ -131,5 +131,5 @@
131
131
  ],
132
132
  "year": 2016
133
133
  },
134
- "gitHead": "7a21075f27ba00b28a6eb77e70918a4c7f4e6e68\n"
134
+ "gitHead": "1107498d31504dc63d1a457b5def387d7a134f69\n"
135
135
  }
package/serialize.js CHANGED
@@ -35,7 +35,11 @@ const serialize = (tree, opts, path = [0]) => {
35
35
  const __serialize = (tree, opts, path) => tree == null ? "" : Array.isArray(tree) ? __serializeElement(tree, opts, path) : isFunction(tree) ? __serialize(tree(opts.ctx), opts, path) : implementsFunction(tree, "toHiccup") ? __serialize(tree.toHiccup(opts.ctx), opts, path) : isDeref(tree) ? __serialize(tree.deref(), opts, path) : isNotStringAndIterable(tree) ? __serializeIter(tree, opts, path) : (tree = __escape(String(tree), opts), opts.span) ? `<span${opts.keys ? ` key="${path.join("-")}"` : ""}>${tree}</span>` : tree;
36
36
  const __serializeElement = (tree, opts, path) => {
37
37
  let tag = tree[0];
38
- return !tree.length ? "" : isFunction(tag) ? __serialize(tag.apply(null, [opts.ctx, ...tree.slice(1)]), opts, path) : implementsFunction(tag, "render") ? __serialize(
38
+ return !tree.length ? "" : isFunction(tag) ? __serialize(
39
+ tag.apply(null, [opts.ctx, ...tree.slice(1)]),
40
+ opts,
41
+ path
42
+ ) : implementsFunction(tag, "render") ? __serialize(
39
43
  tag.render.apply(null, [opts.ctx, ...tree.slice(1)]),
40
44
  opts,
41
45
  path
@@ -48,7 +52,12 @@ const __serializeTag = (tree, opts, path) => {
48
52
  opts.keys && attribs.key === void 0 && (attribs.key = path.join("-"));
49
53
  if (attribs.__escape != null) opts = { ...opts, escape: attribs.__escape };
50
54
  const tag = tree[0];
51
- const body = tree[2] ? __serializeBody(tag, tree[2], opts, path) : !VOID_TAGS[tag] && !NO_CLOSE_EMPTY[tag] ? `></${tag}>` : PROC_TAGS[tag] || "/>";
55
+ let body = tree[2];
56
+ if (body == null && tag === "textarea" && attribs.value) {
57
+ body = attribs.value;
58
+ attribs.value = void 0;
59
+ }
60
+ body = body != null ? __serializeBody(tag, body, opts, path) : !VOID_TAGS[tag] && !NO_CLOSE_EMPTY[tag] ? `></${tag}>` : PROC_TAGS[tag] || "/>";
52
61
  return `<${tag}${__serializeAttribs(attribs, opts)}${body}`;
53
62
  };
54
63
  const __serializeAttribs = (attribs, opts) => {