3030
3131## What is this?  
3232
33- This package lets you find nodes in a tree, similar to how ` matches ` ,
34- ` querySelector ` , and ` querySelectorAll `  work with the DOM.
33+ This package lets you find nodes in a tree,
34+ similar to how ` matches ` ,
35+ ` querySelector ` ,
36+ and
37+ ` querySelectorAll `  work with the DOM.
3538
3639One notable difference between DOM and hast is that DOM nodes have references
37- to their parents, meaning that ` document.body.matches(':last-child') `  can
38- be evaluated to check whether the body is the last child of its parent.
39- This information is not stored in hast, so selectors like that don’t work.
40+ to their parents,
41+ meaning that ` document.body.matches(':last-child') `  can be evaluated to check
42+ whether the body is the last child of its parent.
43+ This information is not stored in hast,
44+ so selectors like that don’t work.
4045
4146## When should I use this?  
4247
43- This is a small utility that is quite useful, but is rather slow if you use it a
44- lot.
45- For each call, it has to walk the entire tree.
48+ This is a small utility that is quite useful,
49+ but is rather slow if you use it a lot.
50+ For each call,
51+ it has to walk the entire tree.
4652In some cases,
47- walking the tree once with [ ` unist-util-visit ` ] [ github-unist-util-visit ] 
48- is smarter, such as when you want to change certain nodes.
49- On the other hand, this is quite powerful and fast enough for many other cases.
53+ walking the tree once with
54+ [ ` unist-util-visit ` ] [ github-unist-util-visit ] 
55+ is smarter,
56+ such as when you want to change certain nodes.
57+ On the other hand,
58+ this is quite powerful and fast enough for many other cases.
5059
5160This utility is similar to
5261[ ` unist-util-select ` ] [ github-unist-util-select ] ,
@@ -55,7 +64,8 @@ which can find and match any unist node.
5564## Install  
5665
5766This package is [ ESM only] [ github-gist-esm ] .
58- In Node.js (version 16+), install with [ npm] [ npmjs-install ] :
67+ In Node.js (version 16+),
68+ install with [ npm] [ npmjs-install ] :
5969
6070``` sh 
6171npm install hast-util-select
@@ -64,14 +74,14 @@ npm install hast-util-select
6474In Deno with [ ` esm.sh ` ] [ esmsh ] :
6575
6676``` js 
67- import  {matches , select , selectAll } from  " https://esm.sh/hast-util-select@6" 
77+ import  {matches , select , selectAll } from  ' https://esm.sh/hast-util-select@6' 
6878``` 
6979
7080In browsers with [ ` esm.sh ` ] [ esmsh ] :
7181
7282``` html 
7383<script  type =" module"  >
74-   import  {matches , select , selectAll } from  " https://esm.sh/hast-util-select@6?bundle"  
84+   import  {matches , select , selectAll } from  ' https://esm.sh/hast-util-select@6?bundle'  
7585 </script >
7686``` 
7787
@@ -103,25 +113,33 @@ console.log(selectAll('h1 ~ :nth-child(even)', tree))
103113## API  
104114
105115This package exports the identifiers [ ` matches ` ] [ api-matches ] ,
106- [ ` select ` ] [ api-select ] , and [ ` selectAll ` ] [ api-select-all ] .
116+ [ ` select ` ] [ api-select ] ,
117+ and [ ` selectAll ` ] [ api-select-all ] .
107118There is no default export.
108119
109120### ` matches(selector, node[, space]) `  
110121
111122Check that the given ` node `  matches ` selector ` .
112123
113- This only checks the element itself, not the surrounding tree.
114- Thus, nesting in selectors is not supported (` p b ` , ` p > b ` ), neither are
115- selectors like ` :first-child ` , etc.
124+ This only checks the element itself,
125+ not the surrounding tree.
126+ Thus,
127+ nesting in selectors is not supported (` p b ` , ` p > b ` ),
128+ neither are selectors like ` :first-child ` ,
129+ etc.
116130This only checks that the given element matches the selector.
117131
118132###### Parameters  
119133
120- *  ` selector `  (` string ` )
121-   — CSS selector, such as (` h1 ` , ` a, b ` )
122- *  ` node `  ([ ` Node ` ] [ github-hast-nodes ] , optional)
123-   — node that might match ` selector ` , should be an element
124- *  ` space `  ([ ` Space ` ] [ api-space ] , default: ` 'html' ` )
134+ *  ` selector ` 
135+   (` string ` , example: ` 'h1' ` , ` 'a, b' ` )
136+   — CSS selector
137+ *  ` node ` 
138+   ([ ` Node ` ] [ github-hast-nodes ] , optional)
139+   — node that might match ` selector ` ,
140+   should be an element
141+ *  ` space ` 
142+   ([ ` Space ` ] [ api-space ] , default: ` 'html' ` )
125143  — name of namespace
126144
127145###### Returns  
@@ -150,11 +168,14 @@ Searches the tree in *[preorder][github-unist-preorder]*.
150168
151169###### Parameters  
152170
153- *  ` selector `  (` string ` )
171+ *  ` selector ` 
172+   (` string ` , example: ` 'h1' ` , ` 'a, b' ` )
154173  — CSS selector, such as (` h1 ` , ` a, b ` )
155- *  ` tree `  ([ ` Node ` ] [ github-hast-nodes ] , optional)
174+ *  ` tree ` 
175+   ([ ` Node ` ] [ github-hast-nodes ] , optional)
156176  — tree to search
157- *  ` space `  ([ ` Space ` ] [ api-space ] , default: ` 'html' ` )
177+ *  ` space ` 
178+   ([ ` Space ` ] [ api-space ] , default: ` 'html' ` )
158179  — name of namespace
159180
160181###### Returns  
@@ -199,11 +220,14 @@ Searches the tree in *[preorder][github-unist-preorder]*.
199220
200221###### Parameters  
201222
202- *  ` selector `  (` string ` )
203-   — CSS selector, such as (` h1 ` , ` a, b ` )
204- *  ` tree `  ([ ` Node ` ] [ github-hast-nodes ] , optional)
223+ *  ` selector ` 
224+   (` string ` , example: ` 'h1' ` , ` 'a, b' ` )
225+   — CSS selector
226+ *  ` tree ` 
227+   ([ ` Node ` ] [ github-hast-nodes ] , optional)
205228  — tree to search
206- *  ` space `  ([ ` Space ` ] [ api-space ] , default: ` 'html' ` )
229+ *  ` space ` 
230+   ([ ` Space ` ] [ api-space ] , default: ` 'html' ` )
207231  — name of namespace
208232
209233###### Returns  
@@ -362,10 +386,14 @@ type Space = 'html' | 'svg'
362386###### Notes 
363387
364388* \*  — not supported in  ` matches ` 
365- * † — needs a user, browser, interactivity, scripting, or whole CSS to make 
366-   sense 
389+ * † — needs a user, 
390+   browser, 
391+   interactivity, 
392+   scripting, 
393+   or whole CSS to make sense 
367394* ‡ — not very interested in writing / including the code for this 
368- * § — too new, the spec is still changing 
395+ * § — too new, 
396+   the spec is still changing 
369397* ‖ — pr wanted! 
370398*  ` : any ()`  and  ` : matches ()`  are renamed to  ` : is ()`  in CSS. 
371399
@@ -379,9 +407,10 @@ It exports the additional type [`Space`][api-space].
379407Projects maintained by the unified collective are compatible with maintained 
380408versions of Node.js. 
381409
382- When we cut a new major release, we drop support for unmaintained versions of 
383- Node. 
384- This means we try to keep the current release line,  ` hast -util -select @^6 ` , 
410+ When we cut a new major release, 
411+ we drop support for unmaintained versions of Node. 
412+ This means we try to keep the current release line, 
413+ ` hast -util -select @6 ` , 
385414compatible with Node.js 16. 
386415
387416## Security 
@@ -409,8 +438,9 @@ for ways to get started.
409438See [ ` support .md ` ][health-support] for ways to get help. 
410439
411440This project has a [code of conduct][health-coc]. 
412- By interacting with this repository, organization, or community you agree to 
413- abide by its terms. 
441+ By interacting with this repository, 
442+ organization, 
443+ or community you agree to abide by its terms. 
414444
415445## License 
416446
0 commit comments