@thi.ng/hiccup 5.1.29 → 5.2.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.
- package/CHANGELOG.md +7 -1
- package/README.md +1 -1
- package/package.json +8 -9
- package/serialize.d.ts +12 -0
- package/serialize.js +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2024-04-
|
|
3
|
+
- **Last updated**: 2024-04-25T19:44:55Z
|
|
4
4
|
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
|
|
5
5
|
|
|
6
6
|
All notable changes to this project will be documented in this file.
|
|
@@ -9,6 +9,12 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
|
|
|
9
9
|
**Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
|
|
10
10
|
and/or version bumps of transitive dependencies.
|
|
11
11
|
|
|
12
|
+
## [5.2.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/hiccup@5.2.0) (2024-04-25)
|
|
13
|
+
|
|
14
|
+
#### 🚀 Features
|
|
15
|
+
|
|
16
|
+
- add `SerializeOpts.xml`, update serializeAttrib ([8fdcab9](https://github.com/thi-ng/umbrella/commit/8fdcab9))
|
|
17
|
+
|
|
12
18
|
### [5.1.29](https://github.com/thi-ng/umbrella/tree/@thi.ng/hiccup@5.1.29) (2024-04-20)
|
|
13
19
|
|
|
14
20
|
#### ♻️ Refactoring
|
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/hiccup",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.2.0",
|
|
4
4
|
"description": "HTML/SVG/XML serialization of nested data structures, iterables & closures",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"build": "yarn build:esbuild && yarn build:decl",
|
|
28
28
|
"build:decl": "tsc --declaration --emitDeclarationOnly",
|
|
29
29
|
"build:esbuild": "esbuild --format=esm --platform=neutral --target=es2022 --tsconfig=tsconfig.json --outdir=. src/**/*.ts",
|
|
30
|
-
"clean": "
|
|
30
|
+
"clean": "bun ../../tools/src/clean-package.ts",
|
|
31
31
|
"doc": "typedoc --excludePrivate --excludeInternal --out doc src/index.ts",
|
|
32
32
|
"doc:ae": "mkdir -p .ae/doc .ae/temp && api-extractor run --local --verbose",
|
|
33
33
|
"doc:readme": "bun ../../tools/src/module-stats.ts && bun ../../tools/src/readme.ts",
|
|
@@ -36,16 +36,15 @@
|
|
|
36
36
|
"tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@thi.ng/api": "^8.11.
|
|
40
|
-
"@thi.ng/checks": "^3.6.
|
|
41
|
-
"@thi.ng/errors": "^2.5.
|
|
42
|
-
"@thi.ng/strings": "^3.7.
|
|
39
|
+
"@thi.ng/api": "^8.11.1",
|
|
40
|
+
"@thi.ng/checks": "^3.6.3",
|
|
41
|
+
"@thi.ng/errors": "^2.5.6",
|
|
42
|
+
"@thi.ng/strings": "^3.7.32"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@microsoft/api-extractor": "^7.43.0",
|
|
46
|
-
"@thi.ng/atom": "^5.2.
|
|
46
|
+
"@thi.ng/atom": "^5.2.45",
|
|
47
47
|
"esbuild": "^0.20.2",
|
|
48
|
-
"rimraf": "^5.0.5",
|
|
49
48
|
"typedoc": "^0.25.12",
|
|
50
49
|
"typescript": "^5.4.3"
|
|
51
50
|
},
|
|
@@ -129,5 +128,5 @@
|
|
|
129
128
|
],
|
|
130
129
|
"year": 2016
|
|
131
130
|
},
|
|
132
|
-
"gitHead": "
|
|
131
|
+
"gitHead": "aed3421c21044c005fbcb7cc37965ccf85a870d2\n"
|
|
133
132
|
}
|
package/serialize.d.ts
CHANGED
|
@@ -36,6 +36,18 @@ export interface SerializeOpts {
|
|
|
36
36
|
* @defaultValue false
|
|
37
37
|
*/
|
|
38
38
|
keys: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* If true, some serialization behaviors will be adjusted to target XML
|
|
41
|
+
* output.
|
|
42
|
+
*
|
|
43
|
+
* @remarks
|
|
44
|
+
* Currently, the following aspects are supported:
|
|
45
|
+
*
|
|
46
|
+
* - boolean attributes are serialized as `name=""` rather than just `name`
|
|
47
|
+
*
|
|
48
|
+
* @defaultValue false
|
|
49
|
+
*/
|
|
50
|
+
xml: boolean;
|
|
39
51
|
}
|
|
40
52
|
/**
|
|
41
53
|
* Recursively normalizes and serializes given tree as HTML/SVG/XML string.
|
package/serialize.js
CHANGED
|
@@ -23,8 +23,9 @@ const serialize = (tree, opts, path = [0]) => {
|
|
|
23
23
|
const $opts = {
|
|
24
24
|
escape: false,
|
|
25
25
|
escapeFn: escapeEntitiesNum,
|
|
26
|
-
span: false,
|
|
27
26
|
keys: false,
|
|
27
|
+
span: false,
|
|
28
|
+
xml: false,
|
|
28
29
|
...opts
|
|
29
30
|
};
|
|
30
31
|
if (opts?.keys == null && $opts.span)
|
|
@@ -61,7 +62,7 @@ const serializeAttribs = (attribs, opts) => {
|
|
|
61
62
|
return res;
|
|
62
63
|
};
|
|
63
64
|
const serializeAttrib = (attribs, a, v, opts) => {
|
|
64
|
-
return v == null ? null : isFunction(v) && (/^on\w+/.test(a) || (v = v(attribs)) == null) ? null : v === true ? " " + a : v === false ? null : a === "data" ? serializeDataAttribs(v, opts) : attribPair(a, v, opts);
|
|
65
|
+
return v == null ? null : isFunction(v) && (/^on\w+/.test(a) || (v = v(attribs)) == null) ? null : v === true ? " " + a + (opts.xml ? `=""` : "") : v === false ? null : a === "data" ? serializeDataAttribs(v, opts) : attribPair(a, v, opts);
|
|
65
66
|
};
|
|
66
67
|
const attribPair = (a, v, opts) => {
|
|
67
68
|
v = a === "style" && isPlainObject(v) ? css(v) : a === "prefix" && isPlainObject(v) ? formatPrefixes(v) : isArray(v) ? v.join(ATTRIB_JOIN_DELIMS[a] || " ") : v.toString();
|