@@ -269,25 +269,18 @@ function applyData(from, to) {
269269 }
270270 // Transforming the node resulted in a non-element, which happens for
271271 // raw, text, and root nodes (unless custom handlers are passed).
272- // The intent is likely to keep the content around (otherwise: pass
273- // `hChildren`).
272+ // The intent of `hName` is to create an element, but likely also to keep
273+ // the content around (otherwise: pass `hChildren`).
274274 else {
275- result = { type : 'element' , tagName : hName , properties : { } , children : [ ] }
276-
277- // To do: next major: take the children from the `root`, or inject the
278- // raw/text/comment or so into the element?
279- // if ('children' in from) {
280- // // @ts -expect-error: assume `children` are allowed in elements.
281- // result.children = from.children
282- // } else {
283- // // @ts -expect-error: assume `node` is allowed in elements.
284- // result.children.push(from)
285- // }
275+ /** @type {Array<HastElementContent> } */
276+ // @ts -expect-error: assume no doctypes in `root`.
277+ const children = 'children' in result ? result . children : [ result ]
278+ result = { type : 'element' , tagName : hName , properties : { } , children}
286279 }
287280 }
288281
289282 if ( result . type === 'element' && hProperties ) {
290- result . properties = { ... result . properties , ... hProperties }
283+ Object . assign ( result . properties , structuredClone ( hProperties ) )
291284 }
292285
293286 if (
0 commit comments