17
17
* [ Install] ( #install )
18
18
* [ Use] ( #use )
19
19
* [ API] ( #api )
20
- * [ ` parseSelector([ selector] [, defaultTagName]) ` ] ( #parseselectorselector-defaulttagname )
20
+ * [ ` parseSelector(selector? [, defaultTagName]) ` ] ( #parseselectorselector-defaulttagname )
21
21
* [ Types] ( #types )
22
22
* [ Compatibility] ( #compatibility )
23
23
* [ Security] ( #security )
@@ -38,7 +38,7 @@ You probably want the more powerful [`hastscript`][hastscript] or
38
38
## Install
39
39
40
40
This package is [ ESM only] [ esm ] .
41
- In Node.js (version 12.20+, 14.14+, 16.0+, or 18 .0+), install with [ npm] [ ] :
41
+ In Node.js (version 14.14+ and 16 .0+), install with [ npm] [ ] :
42
42
43
43
``` sh
44
44
npm install hast-util-parse-selector
@@ -77,37 +77,39 @@ Yields:
77
77
78
78
## API
79
79
80
- This package exports the identifier ` parseSelector ` .
80
+ This package exports the identifier [ ` parseSelector ` ] [ parseselector ] .
81
81
There is no default export.
82
82
83
- ### ` parseSelector([ selector] [, defaultTagName]) `
83
+ ### ` parseSelector(selector? [, defaultTagName]) `
84
84
85
- Create an [ * element * ] [ element ] [ * node * ] [ node ] from a simple CSS selector.
85
+ Create a hast element from a simple CSS selector.
86
86
87
87
###### Parameters
88
88
89
89
* ` selector ` (` string ` , optional)
90
- — can contain a tag name (` foo ` ), classes (` .bar ` ), and an ID (` #baz ` ),
91
- multiple classes are allowed, and uses the last ID if multiple IDs are found
90
+ — simple CSS selector, can contain a tag name (` foo ` ), classes (` .bar ` ),
91
+ and an ID (` #baz ` ), multiple classes are allowed, uses the last ID if
92
+ multiple IDs are found
92
93
* ` defaultTagName ` (` string ` , default: ` 'div' ` )
93
94
— tag name to use if ` selector ` does not specify one
94
95
95
96
###### Returns
96
97
97
- [ ` Element ` ] [ element ] .
98
+ Built element ( [ ` Element ` ] [ element ] ) .
98
99
99
100
## Types
100
101
101
102
This package is fully typed with [ TypeScript] [ ] .
102
103
It exports no additional types.
104
+
103
105
In TypeScript 4.2+, the type system can infer the tag name of literal
104
106
` selector ` s and knows that the return element has that name.
105
107
106
108
## Compatibility
107
109
108
110
Projects maintained by the unified collective are compatible with all maintained
109
111
versions of Node.js.
110
- As of now, that is Node.js 12.20+, 14.14+, 16.0+, and 18 .0+.
112
+ As of now, that is Node.js 14.14+ and 16 .0+.
111
113
Our projects sometimes work with older versions, but this is not guaranteed.
112
114
113
115
## Security
@@ -194,8 +196,8 @@ abide by its terms.
194
196
195
197
[ hast-util-from-selector ] : https://github.com/syntax-tree/hast-util-from-selector
196
198
197
- [ node ] : https://github.com/syntax-tree/hast#nodes
198
-
199
199
[ element ] : https://github.com/syntax-tree/hast#element
200
200
201
201
[ xss ] : https://en.wikipedia.org/wiki/Cross-site_scripting
202
+
203
+ [ parseselector ] : #parseselectorselector-defaulttagname
0 commit comments