1
1
/**
2
- * @typedef {import('hast').Parent } HastParent
3
2
* @typedef {import('hast').Root } HastRoot
4
3
* @typedef {import('hast').DocType } HastDoctype
5
4
* @typedef {import('hast').Element } HastElement
6
5
* @typedef {import('hast').Text } HastText
7
6
* @typedef {import('hast').Comment } HastComment
8
- * @typedef {HastParent['children'][number] } HastChild
7
+ * @typedef {import('hast').Content } HastChild
9
8
* @typedef {HastChild|HastRoot } HastNode
10
9
*
11
10
* @callback AfterTransform
17
16
* @returns {void }
18
17
*
19
18
* @typedef Options
19
+ * Configuration (optional).
20
20
* @property {boolean } [fragment=false]
21
21
* Whether a DOM fragment should be returned
22
22
* @property {Document } [document]
34
34
* @property {AfterTransform } [afterTransform]
35
35
*/
36
36
37
+ /* eslint-env browser */
38
+
37
39
import { webNamespaces } from 'web-namespaces'
38
40
import { find , html , svg } from 'property-information'
39
41
40
- /* eslint-env browser */
42
+ /**
43
+ * Transform a hast tree to a DOM tree
44
+ *
45
+ * @param {HastNode } node
46
+ * @param {Options } [options]
47
+ * @returns {Node }
48
+ */
49
+ export function toDom ( node , options = { } ) {
50
+ const { document : doc = document , ...rest } = options
51
+ return transform ( node , { doc, ...rest } )
52
+ }
41
53
42
54
/**
43
55
* @param {HastNode } node
@@ -243,7 +255,7 @@ function element(node, ctx) {
243
255
*
244
256
* @template {Node} N
245
257
* @param {N } node
246
- * @param {Array. <HastChild> } children
258
+ * @param {Array<HastChild> } children
247
259
* @param {Context } ctx
248
260
* @returns {N }
249
261
*/
@@ -257,15 +269,3 @@ function appendAll(node, children, ctx) {
257
269
258
270
return node
259
271
}
260
-
261
- /**
262
- * Transform a hast tree to a DOM tree
263
- *
264
- * @param {HastNode } node
265
- * @param {Options } [options]
266
- * @returns {Node }
267
- */
268
- export function toDom ( node , options = { } ) {
269
- const { document : doc = document , ...rest } = options
270
- return transform ( node , { doc, ...rest } )
271
- }
0 commit comments