11/**
22 * @typedef {import('hast').Root } Root
3+ * @typedef {import('hast').Content } Content
34 * @typedef {import('hast').Element } Element
45 * @typedef {import('hast').Properties } Properties
5- * @typedef {Root['children'][number] } Child
6- * @typedef {Child|Root } Node
76 * @typedef {import('property-information').Info } Info
87 * @typedef {import('property-information').Schema } Schema
8+ */
9+
10+ /**
11+ * @typedef {Content | Root } Node
12+ * Any concrete `hast` node.
13+ * @typedef {Root | Element } HResult
14+ * Result from a `h` (or `s`) call.
915 *
10- * @typedef {Root|Element } HResult
11- * @typedef { string|number } HStyleValue
16+ * @typedef {string | number } HStyleValue
17+ * Value for a CSS style field.
1218 * @typedef {Record<string, HStyleValue> } HStyle
13- * @typedef {string|number|boolean|null|undefined } HPrimitiveValue
14- * @typedef {Array<string|number> } HArrayValue
15- * @typedef {HPrimitiveValue|HArrayValue } HPropertyValue
16- * @typedef {{[property: string]: HPropertyValue|HStyle} } HProperties
17- * Acceptable properties value.
19+ * Supported value of a `style` prop.
20+ * @typedef {string | number | boolean | null | undefined } HPrimitiveValue
21+ * Primitive property value.
22+ * @typedef {Array<string | number> } HArrayValue
23+ * List of property values for space- or comma separated values (such as `className`).
24+ * @typedef {HPrimitiveValue | HArrayValue } HPropertyValue
25+ * Primitive value or list value.
26+ * @typedef {{[property: string]: HPropertyValue | HStyle} } HProperties
27+ * Acceptable value for element properties.
1828 *
19- * @typedef {string|number|null|undefined } HPrimitiveChild
20- * @typedef {Array<Node|HPrimitiveChild> } HArrayChild
21- * @typedef {Node|HPrimitiveChild|HArrayChild } HChild
22- * Acceptable child value
29+ * @typedef {string | number | null | undefined } HPrimitiveChild
30+ * Primitive children, either ignored (nullish), or turned into text nodes.
31+ * @typedef {Array<Node | HPrimitiveChild> } HArrayChild
32+ * List of children.
33+ * @typedef {Node | HPrimitiveChild | HArrayChild } HChild
34+ * Acceptable child value.
2335 */
2436
2537import { find , normalize } from 'property-information'
@@ -43,7 +55,7 @@ export function core(schema, defaultTagName, caseSensitive) {
4355 /**
4456 * @type {{
4557 * (): Root
46- * (selector: null| undefined, ...children: Array<HChild>): Root
58+ * (selector: null | undefined, ...children: Array<HChild>): Root
4759 * (selector: string, properties?: HProperties, ...children: Array<HChild>): Element
4860 * (selector: string, ...children: Array<HChild>): Element
4961 * }}
@@ -52,8 +64,8 @@ export function core(schema, defaultTagName, caseSensitive) {
5264 /**
5365 * Hyperscript compatible DSL for creating virtual hast trees.
5466 *
55- * @param {string| null } [selector]
56- * @param {HProperties| HChild } [properties]
67+ * @param {string | null } [selector]
68+ * @param {HProperties | HChild } [properties]
5769 * @param {Array<HChild> } children
5870 * @returns {HResult }
5971 */
@@ -108,7 +120,7 @@ export function core(schema, defaultTagName, caseSensitive) {
108120}
109121
110122/**
111- * @param {HProperties| HChild } value
123+ * @param {HProperties | HChild } value
112124 * @param {string } name
113125 * @returns {value is HProperties }
114126 */
@@ -141,7 +153,7 @@ function isProperties(value, name) {
141153 * @param {Schema } schema
142154 * @param {Properties } properties
143155 * @param {string } key
144- * @param {HStyle| HPropertyValue } value
156+ * @param {HStyle | HPropertyValue } value
145157 * @returns {void }
146158 */
147159function addProperty ( schema , properties , key , value ) {
@@ -181,7 +193,7 @@ function addProperty(schema, properties, key, value) {
181193 }
182194
183195 if ( Array . isArray ( result ) ) {
184- /** @type {Array<string| number> } */
196+ /** @type {Array<string | number> } */
185197 const finalResult = [ ]
186198
187199 while ( ++ index < result . length ) {
@@ -202,7 +214,7 @@ function addProperty(schema, properties, key, value) {
202214}
203215
204216/**
205- * @param {Array<Child > } nodes
217+ * @param {Array<Content > } nodes
206218 * @param {HChild } value
207219 * @returns {void }
208220 */
@@ -254,8 +266,12 @@ function parsePrimitive(info, name, value) {
254266}
255267
256268/**
269+ * Serialize a `style` object as a string.
270+ *
257271 * @param {HStyle } value
272+ * Style object.
258273 * @returns {string }
274+ * CSS string.
259275 */
260276function style ( value ) {
261277 /** @type {Array<string> } */
@@ -273,8 +289,12 @@ function style(value) {
273289}
274290
275291/**
292+ * Create a map to adjust casing.
293+ *
276294 * @param {Array<string> } values
295+ * List of properly cased keys.
277296 * @returns {Record<string, string> }
297+ * Map of lowercase keys to uppercase keys.
278298 */
279299function createAdjustMap ( values ) {
280300 /** @type {Record<string, string> } */
0 commit comments