@@ -83,16 +83,26 @@ There is no default export.
8383
8484### ` matches(selector, node[, space]) `
8585
86- Check that the given ` node ` ([ ` Node ` ] [ node ] , should be [ element] [ ] ) matches the
87- CSS selector ` selector ` (` string ` , stuff like ` a, b ` is also supported).
88- Also accepts a ` space ` (enum, ` 'svg' ` or ` 'html' ` , default: ` 'html' ` )
89- Returns whether the node matches or not (` boolean ` ).
86+ Check that the given ` node ` matches ` selector ` .
9087
9188This only checks the element itself, not the surrounding tree.
9289Thus, nesting in selectors is not supported (` p b ` , ` p > b ` ), neither are
9390selectors like ` :first-child ` , etc.
9491This only checks that the given element matches the selector.
9592
93+ ###### Parameters
94+
95+ * ` selector ` (` string ` )
96+ — CSS selector, such as (` h1 ` , ` a, b ` )
97+ * ` node ` ([ ` Node ` ] [ node ] , optional)
98+ — node that might match ` selector ` , should be an element
99+ * ` space ` (` 'svg' ` or ` 'html' ` , default: ` 'html' ` )
100+ — name of namespace
101+
102+ ###### Returns
103+
104+ Whether ` node ` matches ` selector ` (` boolean ` ).
105+
96106###### Example
97107
98108``` js
@@ -106,15 +116,27 @@ matches('.classy', h('a', {className: ['classy']})) // => true
106116matches (' #id' , h (' a' , {id: ' id' })) // => true
107117matches (' [lang|=en]' , h (' a' , {lang: ' en' })) // => true
108118matches (' [lang|=en]' , h (' a' , {lang: ' en-GB' })) // => true
109- // ...
119+ // …
110120```
111121
112122### ` select(selector, tree[, space]) `
113123
114- Select the first [ element] [ ] (or ` null ` ) matching the CSS selector ` selector ` in
115- the given ` tree ` ([ ` Node ` ] [ node ] ), which could be the tree itself.
116- Searches the [ tree] [ ] in * [ preorder] [ ] * .
117- Also accepts a ` space ` (enum, ` 'svg' ` or ` 'html' ` , default: ` 'html' ` )
124+ Select the first element that matches ` selector ` in the given ` tree ` .
125+ Searches the tree in * [ preorder] [ ] * .
126+
127+ ###### Parameters
128+
129+ * ` selector ` (` string ` )
130+ — CSS selector, such as (` h1 ` , ` a, b ` )
131+ * ` tree ` ([ ` Node ` ] [ node ] , optional)
132+ — tree to search
133+ * ` space ` (` 'svg' ` or ` 'html' ` , default: ` 'html' ` )
134+ — name of namespace
135+
136+ ###### Returns
137+
138+ First element in ` tree ` that matches ` selector ` or ` null ` if nothing is found.
139+ This could be ` tree ` itself.
118140
119141###### Example
120142
@@ -147,10 +169,22 @@ Yields:
147169
148170### ` selectAll(selector, tree[, space]) `
149171
150- Select all [ element] [ ] s (` Array<Element> ` ) matching the CSS selector ` selector `
151- in the given ` tree ` ([ ` Node ` ] [ node ] ), which could include the tree itself.
152- Searches the [ tree] [ ] in * [ preorder] [ ] * .
153- Also accepts a ` space ` (enum, ` 'svg' ` or ` 'html' ` , default: ` 'html' ` )
172+ Select all elements that match ` selector ` in the given ` tree ` .
173+ Searches the tree in * preorder* .
174+
175+ ###### Parameters
176+
177+ * ` selector ` (` string ` )
178+ — CSS selector, such as (` h1 ` , ` a, b ` )
179+ * ` tree ` ([ ` Node ` ] [ node ] , optional)
180+ — tree to search
181+ * ` space ` (` 'svg' ` or ` 'html' ` , default: ` 'html' ` )
182+ — name of namespace
183+
184+ ###### Returns
185+
186+ Elements in ` tree ` that match ` selector ` .
187+ This could include ` tree ` itself.
154188
155189###### Example
156190
@@ -385,16 +419,12 @@ abide by its terms.
385419
386420[ coc ] : https://github.com/syntax-tree/.github/blob/main/code-of-conduct.md
387421
388- [ tree ] : https://github.com/syntax-tree/unist#tree
389-
390422[ preorder ] : https://github.com/syntax-tree/unist#preorder
391423
392424[ hast ] : https://github.com/syntax-tree/hast
393425
394426[ node ] : https://github.com/syntax-tree/hast#nodes
395427
396- [ element ] : https://github.com/syntax-tree/hast#element
397-
398428[ xss ] : https://en.wikipedia.org/wiki/Cross-site_scripting
399429
400430[ unist-util-visit ] : https://github.com/syntax-tree/unist-util-visit
0 commit comments