@@ -35,13 +35,25 @@ There is no default export.
3535
3636### ` matches(selector, node) `
3737
38- Check that the given [ node] [ ] matches ` selector ` .
39- Returns ` boolean ` , whether the node matches or not.
38+ Check that the given ` node ` matches ` selector ` .
4039
41- This only checks the element itself, not the surrounding tree.
40+ This only checks the node itself, not the surrounding tree.
4241Thus, nesting in selectors is not supported (` paragraph strong ` ,
43- ` paragraph > strong ` ), nor are selectors like ` :first-child ` , etc.
44- This only checks that the given element matches the selector.
42+ ` paragraph > strong ` ), neither are selectors like ` :first-child ` , etc.
43+ This only checks that the given node matches the selector.
44+
45+ ###### Parameters
46+
47+ * ` selector ` (` string ` )
48+ — CSS selector, such as (` heading ` , ` link, linkReference ` ).
49+ * ` node ` ([ ` Node ` ] [ node ] , optional)
50+ — node that might match ` selector `
51+
52+ ###### Returns
53+
54+ Whether ` node ` matches ` selector ` (` boolean ` ).
55+
56+ ###### Example
4557
4658``` js
4759import {u } from ' unist-builder'
@@ -53,9 +65,24 @@ matches('[lang]', u('code', {lang: 'js'}, 'console.log(1)')) // => true
5365
5466### ` select(selector, tree) `
5567
56- Select the first node matching ` selector ` in the given ` tree ` (could be the
57- tree itself).
58- Returns the found [ node] [ ] , if any.
68+ Select the first node that matches ` selector ` in the given ` tree ` .
69+
70+ Searches the tree in * [ preorder] [ ] * .
71+
72+ ###### Parameters
73+
74+ * ` selector ` (` string ` )
75+ — CSS selector, such as (` heading ` , ` link, linkReference ` ).
76+ * ` tree ` ([ ` Node ` ] [ node ] , optional)
77+ — tree to search
78+
79+ ###### Returns
80+
81+ First node in ` tree ` that matches ` selector ` or ` null ` if nothing is found.
82+
83+ This could be ` tree ` itself.
84+
85+ ###### Example
5986
6087``` js
6188import {u } from ' unist-builder'
@@ -83,9 +110,24 @@ Yields:
83110
84111### ` selectAll(selector, tree) `
85112
86- Select all nodes matching ` selector ` in the given ` tree ` (could include the
87- tree itself).
88- Returns all found [ node] [ ] s, if any.
113+ Select all nodes that match ` selector ` in the given ` tree ` .
114+
115+ Searches the tree in * [ preorder] [ ] * .
116+
117+ ###### Parameters
118+
119+ * ` selector ` (` string ` )
120+ — CSS selector, such as (` heading ` , ` link, linkReference ` ).
121+ * ` tree ` ([ ` Node ` ] [ node ] , optional)
122+ — tree to search
123+
124+ ###### Returns
125+
126+ Nodes in ` tree ` that match ` selector ` .
127+
128+ This could include ` tree ` itself.
129+
130+ ###### Example
89131
90132``` js
91133import {u } from ' unist-builder'
@@ -232,6 +274,8 @@ abide by its terms.
232274
233275[ coc ] : https://github.com/syntax-tree/.github/blob/HEAD/code-of-conduct.md
234276
277+ [ preorder ] : https://github.com/syntax-tree/unist#preorder
278+
235279[ unist ] : https://github.com/syntax-tree/unist
236280
237281[ node ] : https://github.com/syntax-tree/unist#node
0 commit comments