@@ -64,6 +64,8 @@ import {find, normalize} from 'property-information'
6464import { parse as parseSpaces } from 'space-separated-tokens'
6565
6666/**
67+ * Create an `h` function.
68+ *
6769 * @param {Schema } schema
6870 * Schema to use.
6971 * @param {string } defaultTagName
@@ -81,19 +83,29 @@ export function createH(schema, defaultTagName, caseSensitive) {
8183 *
8284 * @overload
8385 * @param {null | undefined } [selector]
86+ * Nothing to get a root.
8487 * @param {...Child } children
88+ * Children.
8589 * @returns {Root }
90+ * Root.
8691 *
8792 * @overload
8893 * @param {string } selector
94+ * Selector.
8995 * @param {Properties } properties
96+ * Properties.
9097 * @param {...Child } children
98+ * Children.
9199 * @returns {Element }
100+ * Element.
92101 *
93102 * @overload
94103 * @param {string } selector
104+ * Selector.
95105 * @param {...Child } children
106+ * Children.
96107 * @returns {Element }
108+ * Element.
97109 *
98110 * @param {string | null | undefined } [selector]
99111 * Selector.
@@ -196,6 +208,8 @@ function isChild(value) {
196208}
197209
198210/**
211+ * Add a property.
212+ *
199213 * @param {Schema } schema
200214 * Schema.
201215 * @param {Properties } properties
@@ -208,13 +222,13 @@ function isChild(value) {
208222 * Nothing.
209223 */
210224function addProperty ( schema , properties , key , value ) {
225+ // Ignore nullish and NaN values.
226+ if ( value === null || value === undefined ) return
227+
211228 const info = find ( schema , key )
212229 /** @type {PropertyValue } */
213230 let result
214231
215- // Ignore nullish and NaN values.
216- if ( value === null || value === undefined ) return
217-
218232 if ( typeof value === 'number' ) {
219233 // Ignore NaN.
220234 if ( Number . isNaN ( value ) ) return
@@ -261,15 +275,16 @@ function addProperty(schema, properties, key, value) {
261275 // Class names (which can be added both on the `selector` and here).
262276 if ( info . property === 'className' && Array . isArray ( properties . className ) ) {
263277 // Assume no booleans in `className`.
264- result = properties . className . concat (
265- /** @type {Array<number | string> | number | string } */ ( result )
266- )
278+ const add = /** @type {Array<number | string> | number | string } */ ( result )
279+ result = [ ...properties . className , ...( Array . isArray ( add ) ? add : [ add ] ) ]
267280 }
268281
269282 properties [ info . property ] = result
270283}
271284
272285/**
286+ * Add a child.
287+ *
273288 * @param {Array<RootContent> } nodes
274289 * Children.
275290 * @param {Child } value
0 commit comments