8
8
[ ![ Backers] [ backers-badge ]] [ collective ]
9
9
[ ![ Chat] [ chat-badge ]] [ chat ]
10
10
11
- Selector support for [ unist] [ ] .
12
- ` querySelector ` , ` querySelectorAll ` , and ` matches ` .
11
+ [ ** unist** ] [ unist ] utility with equivalents ` querySelector ` , ` querySelectorAll ` ,
12
+ and ` matches ` .
13
13
14
14
Note that the DOM has references to their parent nodes, meaning that
15
15
` document.body.matches(':last-child') ` can be evaluated.
16
16
This information is not stored in unist, so selectors like that don’t work.
17
17
18
18
[ View the list of supported selectors »] [ support ]
19
19
20
- ## Installation
20
+ ## Install
21
21
22
22
[ npm] [ ] :
23
23
24
- ``` bash
24
+ ``` sh
25
25
npm install unist-util-select
26
26
```
27
27
@@ -35,13 +35,13 @@ Returns `boolean`, whether the node matches or not.
35
35
This only checks the element itself, not the surrounding tree.
36
36
Thus, nesting in selectors is not supported (` paragraph strong ` ,
37
37
` paragraph > strong ` ), nor are selectors like ` :first-child ` , etc.
38
- This simply checks that the given element matches the selector.
38
+ This only checks that the given element matches the selector.
39
39
40
- ``` javascript
40
+ ``` js
41
41
var u = require (' unist-builder' )
42
42
var matches = require (' unist-util-select' ).matches
43
43
44
- matches (' strong, em' , u (' strong' , [u (' text' , ' bold ' )])) // => true
44
+ matches (' strong, em' , u (' strong' , [u (' text' , ' important ' )])) // => true
45
45
matches (' [lang]' , u (' code' , {lang: ' js' }, ' console.log(1)' )) // => true
46
46
```
47
47
@@ -51,7 +51,7 @@ Select the first node matching `selector` in the given `tree` (could be the
51
51
tree itself).
52
52
Returns the found [ node] [ ] , if any.
53
53
54
- ``` javascript
54
+ ``` js
55
55
var u = require (' unist-builder' )
56
56
var select = require (' unist-util-select' ).select
57
57
@@ -71,7 +71,7 @@ console.log(
71
71
72
72
Yields:
73
73
74
- ``` javascript
74
+ ``` js
75
75
{ type: ' paragraph' ,
76
76
children: [ { type: ' text' , value: ' Delta' } ] }
77
77
```
@@ -82,7 +82,7 @@ Select all nodes matching `selector` in the given `tree` (could include the
82
82
tree itself).
83
83
Returns all found [ node] [ ] s, if any.
84
84
85
- ``` javascript
85
+ ``` js
86
86
var u = require (' unist-builder' )
87
87
var selectAll = require (' unist-util-select' ).selectAll
88
88
@@ -104,7 +104,7 @@ console.log(
104
104
105
105
Yields:
106
106
107
- ``` javascript
107
+ ``` js
108
108
[ { type: ' paragraph' ,
109
109
children: [ { type: ' text' , value: ' Delta' } ] },
110
110
{ type: ' paragraph' ,
@@ -113,8 +113,6 @@ Yields:
113
113
114
114
## Support
115
115
116
- <!-- lint ignore no-html-->
117
-
118
116
* [x] ` * ` (universal selector)
119
117
* [x] ` , ` (multiple selector)
120
118
* [x] ` paragraph ` (type selector)
@@ -158,11 +156,13 @@ Yields:
158
156
159
157
## Contribute
160
158
161
- See [ ` contributing.md ` in ` syntax-tree/unist ` ] [ contributing ] for ways to get
159
+ See [ ` contributing.md ` in ` syntax-tree/.github ` ] [ contributing ] for ways to get
162
160
started.
161
+ See [ ` support.md ` ] [ help ] for ways to get help.
163
162
164
- This organisation has a [ Code of Conduct] [ coc ] . By interacting with this
165
- repository, organisation, or community you agree to abide by its terms.
163
+ This project has a [ Code of Conduct] [ coc ] .
164
+ By interacting with this repository, organisation, or community you agree to
165
+ abide by its terms.
166
166
167
167
## License
168
168
@@ -200,12 +200,14 @@ repository, organisation, or community you agree to abide by its terms.
200
200
201
201
[ license ] : license
202
202
203
+ [ contributing ] : https://github.com/syntax-tree/.github/blob/master/contributing.md
204
+
205
+ [ help ] : https://github.com/syntax-tree/.github/blob/master/support.md
206
+
207
+ [ coc ] : https://github.com/syntax-tree/.github/blob/master/code-of-conduct.md
208
+
203
209
[ unist ] : https://github.com/syntax-tree/unist
204
210
205
211
[ node ] : https://github.com/syntax-tree/unist#node
206
212
207
213
[ support ] : #support
208
-
209
- [ contributing ] : https://github.com/syntax-tree/unist/blob/master/contributing.md
210
-
211
- [ coc ] : https://github.com/syntax-tree/unist/blob/master/code-of-conduct.md
0 commit comments