17
17
* [ Install] ( #install )
18
18
* [ Use] ( #use )
19
19
* [ API] ( #api )
20
- * [ ` fromSelector([selector][, options]) ` ] ( #fromselectorselector-options )
20
+ * [ ` fromSelector(selector?[, options|space]) ` ] ( #fromselectorselector-optionsspace )
21
+ * [ ` Options ` ] ( #options )
22
+ * [ ` Space ` ] ( #space )
21
23
* [ Support] ( #support )
22
24
* [ Types] ( #types )
23
25
* [ Compatibility] ( #compatibility )
@@ -41,7 +43,7 @@ and similar to [`hastscript`][hastscript].
41
43
## Install
42
44
43
45
This package is [ ESM only] [ esm ] .
44
- In Node.js (version 12.20+, 14.14+, 16.0+, or 18 .0+), install with [ npm] [ ] :
46
+ In Node.js (version 14.14+ and 16 .0+), install with [ npm] [ ] :
45
47
46
48
``` sh
47
49
npm install hast-util-from-selector
@@ -96,27 +98,46 @@ Yields:
96
98
97
99
## API
98
100
99
- This package exports the identifier ` fromSelector ` .
101
+ This package exports the identifier [ ` fromSelector ` ] [ fromselector ] .
100
102
There is no default export.
101
103
102
- ### ` fromSelector([ selector] [, options]) `
104
+ ### ` fromSelector(selector? [, options|space ]) `
103
105
104
- Create one or more [ * element * ] [ element ] s from a CSS selector.
106
+ Create one or more [ ` Element ` ] [ element ] s from a CSS selector.
105
107
106
108
###### Parameters
107
109
108
110
* ` selector ` (` string ` , optional)
109
111
— CSS selector
110
- * ` space ` (` string ` , optional)
112
+ * ` options ` ([ ` Options ` ] [ options ] , optional)
113
+ — configuration
114
+ * ` space ` ([ ` Space ` ] [ space ] , optional)
111
115
— treated as ` options.space `
112
- * ` options.space ` (enum, ` 'svg' ` or ` 'html' ` , default: ` 'html' ` )
116
+
117
+ ###### Returns
118
+
119
+ [ ` Element ` ] [ element ] .
120
+
121
+ ### ` Options `
122
+
123
+ Configuration (TypeScript type).
124
+
125
+ ###### Fields
126
+
127
+ * ` space ` ([ ` Space ` ] [ space ] , optional)
113
128
— which space first element in the selector is in.
114
129
When an ` svg ` element is created in HTML, the space is automatically
115
130
switched to SVG
116
131
117
- ###### Returns
132
+ ### ` Space `
118
133
119
- [ ` Element ` ] [ element ] .
134
+ Name of namespace (TypeScript type).
135
+
136
+ ###### Type
137
+
138
+ ``` ts
139
+ type Space = ' html' | ' svg'
140
+ ` ` `
120
141
121
142
## Support
122
143
@@ -134,19 +155,20 @@ Create one or more [*element*][element]s from a CSS selector.
134
155
## Types
135
156
136
157
This package is fully typed with [TypeScript][].
137
- It exports the additional types ` Options ` and ` Space ` .
158
+ It exports the additional types [ ` Options ` ][options] and [ ` Space ` ][space] .
138
159
139
160
## Compatibility
140
161
141
162
Projects maintained by the unified collective are compatible with all maintained
142
163
versions of Node.js.
143
- As of now, that is Node.js 12.20+, 14.14+, 16.0+, and 18 .0+.
164
+ As of now, that is Node.js 14.14+ and 16 .0+.
144
165
Our projects sometimes work with older versions, but this is not guaranteed.
145
166
146
167
## Security
147
168
148
- Use of ` from-selector ` can open you up to a [ cross-site scripting (XSS)] [ xss ]
149
- attack as values are injected into the syntax tree.
169
+ Use of ` hast -util -from -selector ` can open you up to a
170
+ [cross-site scripting (XSS)][xss] attack as values are injected into the syntax
171
+ tree.
150
172
151
173
Either do not use user input in ` from -selector ` or use
152
174
[ ` hast -util -santize ` ][hast-util-sanitize].
@@ -229,3 +251,9 @@ abide by its terms.
229
251
[hast-util-parse-selector]: https://github.com/syntax-tree/hast-util-parse-selector
230
252
231
253
[hastscript]: https://github.com/syntax-tree/hastscript
254
+
255
+ [fromselector]: #fromselectorselector-optionsspace
256
+
257
+ [options]: #options
258
+
259
+ [space]: #space
0 commit comments