@thi.ng/hiccup 4.2.26 → 4.2.28

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2022-12-16T12:52:25Z
3
+ - **Last updated**: 2022-12-22T21:47:07Z
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.
package/README.md CHANGED
@@ -41,7 +41,7 @@ This project is part of the
41
41
 
42
42
  ## About
43
43
 
44
- HTML/SVG/XML serialization of nested data structures, iterables & closures
44
+ HTML/SVG/XML serialization of nested data structures, iterables & closures.
45
45
 
46
46
  Inspired by [Hiccup](https://github.com/weavejester/hiccup) and
47
47
  [Reagent](http://reagent-project.github.io/) for Clojure/ClojureScript.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/hiccup",
3
- "version": "4.2.26",
3
+ "version": "4.2.28",
4
4
  "description": "HTML/SVG/XML serialization of nested data structures, iterables & closures",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -34,15 +34,15 @@
34
34
  "test": "testament test"
35
35
  },
36
36
  "dependencies": {
37
- "@thi.ng/api": "^8.6.0",
38
- "@thi.ng/checks": "^3.3.5",
39
- "@thi.ng/errors": "^2.2.6",
40
- "@thi.ng/strings": "^3.3.20"
37
+ "@thi.ng/api": "^8.6.2",
38
+ "@thi.ng/checks": "^3.3.6",
39
+ "@thi.ng/errors": "^2.2.7",
40
+ "@thi.ng/strings": "^3.3.22"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@microsoft/api-extractor": "^7.33.7",
44
- "@thi.ng/atom": "^5.1.25",
45
- "@thi.ng/testament": "^0.3.7",
44
+ "@thi.ng/atom": "^5.1.27",
45
+ "@thi.ng/testament": "^0.3.8",
46
46
  "rimraf": "^3.0.2",
47
47
  "tools": "^0.0.1",
48
48
  "typedoc": "^0.23.22",
@@ -120,5 +120,5 @@
120
120
  ],
121
121
  "year": 2016
122
122
  },
123
- "gitHead": "f445a9cc8022bcdebbf6ff91fd66ced016d72f01\n"
123
+ "gitHead": "bc6f7f5e2765bb96fe64db804eaf4b2443b47fc6\n"
124
124
  }
package/serialize.d.ts CHANGED
@@ -1,10 +1,9 @@
1
1
  /**
2
- * Recursively normalizes and serializes given tree as HTML/SVG/XML
3
- * string. Expands any embedded component functions with their results.
2
+ * Recursively normalizes and serializes given tree as HTML/SVG/XML string.
3
+ * Expands any embedded component functions with their results.
4
4
  *
5
5
  * @remarks
6
- * Each node of the input tree can have one of the following input
7
- * forms:
6
+ * Each node of the input tree can have one of the following input forms:
8
7
  *
9
8
  * ```js
10
9
  * ["tag", ...]
@@ -22,14 +21,13 @@
22
21
  * ["div#foo.bar.baz", "hi"] // <div id="foo" class="bar baz">hi</div>
23
22
  * ```
24
23
  *
25
- * The presence of the attributes object (2nd array index) is optional.
26
- * Any attribute values, incl. functions are allowed. If the latter, the
27
- * function is called with the full attribs object as argument and the
28
- * return value is used for the attribute. This allows for the dynamic
29
- * creation of attrib values based on other attribs. The only exception
30
- * to this are event attributes, i.e. attribute names starting with
31
- * "on". Function values assigned to event attributes will be omitted
32
- * from the output.
24
+ * The presence of the attributes object (2nd array index) is optional. Any
25
+ * attribute values, incl. functions are allowed. If the latter, the function is
26
+ * called with the full attribs object as argument and the return value is used
27
+ * for the attribute. This allows for the dynamic creation of attrib values
28
+ * based on other attribs. The only exception to this are event attributes, i.e.
29
+ * attribute names starting with "on". Function values assigned to event
30
+ * attributes will be omitted from the output.
33
31
  *
34
32
  * ```js
35
33
  * ["div#foo", { bar: (attribs) => attribs.id + "-bar" }]
@@ -43,23 +41,24 @@
43
41
  * // <div style="color:red;background:#000;"></div>
44
42
  * ```
45
43
  *
46
- * Boolean attribs are serialized in HTML5 syntax (present or not).
47
- * `null`, `undefined` or empty string attrib values are ignored.
44
+ * Boolean attribs are serialized in HTML5 syntax (present or not). `null`,
45
+ * `undefined` or empty string attrib values are ignored.
48
46
  *
49
- * Any `null` or `undefined` array values (other than in head position)
50
- * will also be removed, unless a function is in head position.
47
+ * Any `null` or `undefined` array values (other than in head position) will
48
+ * also be removed, unless a function is in head position.
51
49
  *
52
- * A function in head position of a node acts as a mechanism for
53
- * component composition & delayed execution. The function will only be
54
- * executed at serialization time. In this case the optional global
55
- * context object and all other elements of that node / array are passed
56
- * as arguments when that function is called. The return value the
57
- * function MUST be a valid new tree (or `undefined`).
50
+ * A function in head position of a node acts as a mechanism for component
51
+ * composition & delayed execution. The function will only be executed at
52
+ * serialization time. In this case the optional global context object and all
53
+ * other elements of that node / array are passed as arguments when that
54
+ * function is called. The return value the function MUST be a valid new tree
55
+ * (or `undefined`).
58
56
  *
59
57
  * If the `ctx` object it'll be passed to each embedded component fns.
60
- * Optionally call {@link derefContext} prior to {@link serialize} to
61
- * auto-deref context keys with values implementing the
62
- * {@link @thi.ng/api#IDeref} interface.
58
+ * Optionally call {@link derefContext} prior to {@link serialize} to auto-deref
59
+ * context keys with values implementing the
60
+ * [`IDeref`](https://docs.thi.ng/umbrella/api/interfaces/IDeref.html)
61
+ * interface.
63
62
  *
64
63
  * ```js
65
64
  * const foo = (ctx, a, b) => ["div#" + a, ctx.foo, b];
@@ -68,29 +67,28 @@
68
67
  * // <div id="id" class="black">body</div>
69
68
  * ```
70
69
  *
71
- * Functions located in other positions are called ONLY with the global
72
- * context arg and can return any (serializable) value (i.e. new trees,
73
- * strings, numbers, iterables or any type with a suitable
74
- * `.toString()`, `.toHiccup()` or `.deref()` implementation).
70
+ * Functions located in other positions are called ONLY with the global context
71
+ * arg and can return any (serializable) value (i.e. new trees, strings,
72
+ * numbers, iterables or any type with a suitable `.toString()`, `.toHiccup()`
73
+ * or `.deref()` implementation).
75
74
  *
76
- * If the optional `span` flag is true (default: false), all text
77
- * content will be wrapped in <span> elements (this is to ensure DOM
78
- * compatibility with hdom). The only elements for spans are never
79
- * created are listed in `NO_SPANS` in `api.ts`.
75
+ * If the optional `span` flag is true (default: false), all text content will
76
+ * be wrapped in <span> elements (this is to ensure DOM compatibility with
77
+ * hdom). The only elements for spans are never created are listed in `NO_SPANS`
78
+ * in `api.ts`.
80
79
  *
81
- * If the optional `keys` flag is true (default: false), all elements
82
- * will have an autogenerated `key` attribute injected. If `span` is
83
- * enabled, `keys` will be enabled by default too (since in this case we
84
- * assume the output is meant to be compatible with
85
- * {@link @thi.ng/hdom# | @thi.ng/hdom}).
80
+ * If the optional `keys` flag is true (default: false), all elements will have
81
+ * an autogenerated `key` attribute injected. If `span` is enabled, `keys` will
82
+ * be enabled by default too (since in this case we assume the output is meant
83
+ * to be compatible with [`thi.ng/hdom`](https://thi.ng/hdom)).
86
84
  *
87
- * hiccup & hdom control attributes (i.e. attrib names prefixed with
88
- * `__`) will be omitted from the output. The only control attrib
89
- * supported by this package is `__serialize`. If set to `false`, the
90
- * entire tree branch will be excluded from the output.
85
+ * hiccup & hdom control attributes (i.e. attrib names prefixed with `__`) will
86
+ * be omitted from the output. The only control attrib supported by this package
87
+ * is `__serialize`. If set to `false`, the entire tree branch will be excluded
88
+ * from the output.
91
89
  *
92
- * Single or multiline comments can be included using the special
93
- * `COMMENT` tag (`__COMMENT__`) (always WITHOUT attributes!).
90
+ * Single or multiline comments can be included using the special `COMMENT` tag
91
+ * (`__COMMENT__`) (always WITHOUT attributes!).
94
92
  *
95
93
  * ```
96
94
  * [COMMENT, "Hello world"]
@@ -111,8 +109,8 @@
111
109
  * - `!ENTITY`
112
110
  * - `!ATTLIST`
113
111
  *
114
- * These are used as follows (attribs are only allowed for `?xml`, all
115
- * others only accept a body string which is taken as is):
112
+ * These are used as follows (attribs are only allowed for `?xml`, all others
113
+ * only accept a body string which is taken as is):
116
114
  *
117
115
  * ```
118
116
  * ["?xml", { version: "1.0", standalone: "yes" }]
package/serialize.js CHANGED
@@ -12,12 +12,11 @@ import { css } from "./css.js";
12
12
  import { normalize } from "./normalize.js";
13
13
  import { formatPrefixes } from "./prefix.js";
14
14
  /**
15
- * Recursively normalizes and serializes given tree as HTML/SVG/XML
16
- * string. Expands any embedded component functions with their results.
15
+ * Recursively normalizes and serializes given tree as HTML/SVG/XML string.
16
+ * Expands any embedded component functions with their results.
17
17
  *
18
18
  * @remarks
19
- * Each node of the input tree can have one of the following input
20
- * forms:
19
+ * Each node of the input tree can have one of the following input forms:
21
20
  *
22
21
  * ```js
23
22
  * ["tag", ...]
@@ -35,14 +34,13 @@ import { formatPrefixes } from "./prefix.js";
35
34
  * ["div#foo.bar.baz", "hi"] // <div id="foo" class="bar baz">hi</div>
36
35
  * ```
37
36
  *
38
- * The presence of the attributes object (2nd array index) is optional.
39
- * Any attribute values, incl. functions are allowed. If the latter, the
40
- * function is called with the full attribs object as argument and the
41
- * return value is used for the attribute. This allows for the dynamic
42
- * creation of attrib values based on other attribs. The only exception
43
- * to this are event attributes, i.e. attribute names starting with
44
- * "on". Function values assigned to event attributes will be omitted
45
- * from the output.
37
+ * The presence of the attributes object (2nd array index) is optional. Any
38
+ * attribute values, incl. functions are allowed. If the latter, the function is
39
+ * called with the full attribs object as argument and the return value is used
40
+ * for the attribute. This allows for the dynamic creation of attrib values
41
+ * based on other attribs. The only exception to this are event attributes, i.e.
42
+ * attribute names starting with "on". Function values assigned to event
43
+ * attributes will be omitted from the output.
46
44
  *
47
45
  * ```js
48
46
  * ["div#foo", { bar: (attribs) => attribs.id + "-bar" }]
@@ -56,23 +54,24 @@ import { formatPrefixes } from "./prefix.js";
56
54
  * // <div style="color:red;background:#000;"></div>
57
55
  * ```
58
56
  *
59
- * Boolean attribs are serialized in HTML5 syntax (present or not).
60
- * `null`, `undefined` or empty string attrib values are ignored.
57
+ * Boolean attribs are serialized in HTML5 syntax (present or not). `null`,
58
+ * `undefined` or empty string attrib values are ignored.
61
59
  *
62
- * Any `null` or `undefined` array values (other than in head position)
63
- * will also be removed, unless a function is in head position.
60
+ * Any `null` or `undefined` array values (other than in head position) will
61
+ * also be removed, unless a function is in head position.
64
62
  *
65
- * A function in head position of a node acts as a mechanism for
66
- * component composition & delayed execution. The function will only be
67
- * executed at serialization time. In this case the optional global
68
- * context object and all other elements of that node / array are passed
69
- * as arguments when that function is called. The return value the
70
- * function MUST be a valid new tree (or `undefined`).
63
+ * A function in head position of a node acts as a mechanism for component
64
+ * composition & delayed execution. The function will only be executed at
65
+ * serialization time. In this case the optional global context object and all
66
+ * other elements of that node / array are passed as arguments when that
67
+ * function is called. The return value the function MUST be a valid new tree
68
+ * (or `undefined`).
71
69
  *
72
70
  * If the `ctx` object it'll be passed to each embedded component fns.
73
- * Optionally call {@link derefContext} prior to {@link serialize} to
74
- * auto-deref context keys with values implementing the
75
- * {@link @thi.ng/api#IDeref} interface.
71
+ * Optionally call {@link derefContext} prior to {@link serialize} to auto-deref
72
+ * context keys with values implementing the
73
+ * [`IDeref`](https://docs.thi.ng/umbrella/api/interfaces/IDeref.html)
74
+ * interface.
76
75
  *
77
76
  * ```js
78
77
  * const foo = (ctx, a, b) => ["div#" + a, ctx.foo, b];
@@ -81,29 +80,28 @@ import { formatPrefixes } from "./prefix.js";
81
80
  * // <div id="id" class="black">body</div>
82
81
  * ```
83
82
  *
84
- * Functions located in other positions are called ONLY with the global
85
- * context arg and can return any (serializable) value (i.e. new trees,
86
- * strings, numbers, iterables or any type with a suitable
87
- * `.toString()`, `.toHiccup()` or `.deref()` implementation).
83
+ * Functions located in other positions are called ONLY with the global context
84
+ * arg and can return any (serializable) value (i.e. new trees, strings,
85
+ * numbers, iterables or any type with a suitable `.toString()`, `.toHiccup()`
86
+ * or `.deref()` implementation).
88
87
  *
89
- * If the optional `span` flag is true (default: false), all text
90
- * content will be wrapped in <span> elements (this is to ensure DOM
91
- * compatibility with hdom). The only elements for spans are never
92
- * created are listed in `NO_SPANS` in `api.ts`.
88
+ * If the optional `span` flag is true (default: false), all text content will
89
+ * be wrapped in <span> elements (this is to ensure DOM compatibility with
90
+ * hdom). The only elements for spans are never created are listed in `NO_SPANS`
91
+ * in `api.ts`.
93
92
  *
94
- * If the optional `keys` flag is true (default: false), all elements
95
- * will have an autogenerated `key` attribute injected. If `span` is
96
- * enabled, `keys` will be enabled by default too (since in this case we
97
- * assume the output is meant to be compatible with
98
- * {@link @thi.ng/hdom# | @thi.ng/hdom}).
93
+ * If the optional `keys` flag is true (default: false), all elements will have
94
+ * an autogenerated `key` attribute injected. If `span` is enabled, `keys` will
95
+ * be enabled by default too (since in this case we assume the output is meant
96
+ * to be compatible with [`thi.ng/hdom`](https://thi.ng/hdom)).
99
97
  *
100
- * hiccup & hdom control attributes (i.e. attrib names prefixed with
101
- * `__`) will be omitted from the output. The only control attrib
102
- * supported by this package is `__serialize`. If set to `false`, the
103
- * entire tree branch will be excluded from the output.
98
+ * hiccup & hdom control attributes (i.e. attrib names prefixed with `__`) will
99
+ * be omitted from the output. The only control attrib supported by this package
100
+ * is `__serialize`. If set to `false`, the entire tree branch will be excluded
101
+ * from the output.
104
102
  *
105
- * Single or multiline comments can be included using the special
106
- * `COMMENT` tag (`__COMMENT__`) (always WITHOUT attributes!).
103
+ * Single or multiline comments can be included using the special `COMMENT` tag
104
+ * (`__COMMENT__`) (always WITHOUT attributes!).
107
105
  *
108
106
  * ```
109
107
  * [COMMENT, "Hello world"]
@@ -124,8 +122,8 @@ import { formatPrefixes } from "./prefix.js";
124
122
  * - `!ENTITY`
125
123
  * - `!ATTLIST`
126
124
  *
127
- * These are used as follows (attribs are only allowed for `?xml`, all
128
- * others only accept a body string which is taken as is):
125
+ * These are used as follows (attribs are only allowed for `?xml`, all others
126
+ * only accept a body string which is taken as is):
129
127
  *
130
128
  * ```
131
129
  * ["?xml", { version: "1.0", standalone: "yes" }]