1717* [ Install] ( #install )
1818* [ Use] ( #use )
1919* [ API] ( #api )
20- * [ ` fromSelector([selector][, options]) ` ] ( #fromselectorselector-options )
20+ * [ ` fromSelector(selector?[, options|space]) ` ] ( #fromselectorselector-optionsspace )
21+ * [ ` Options ` ] ( #options )
22+ * [ ` Space ` ] ( #space )
2123* [ Support] ( #support )
2224* [ Types] ( #types )
2325* [ Compatibility] ( #compatibility )
@@ -41,7 +43,7 @@ and similar to [`hastscript`][hastscript].
4143## Install
4244
4345This 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] [ ] :
4547
4648``` sh
4749npm install hast-util-from-selector
@@ -96,27 +98,46 @@ Yields:
9698
9799## API
98100
99- This package exports the identifier ` fromSelector ` .
101+ This package exports the identifier [ ` fromSelector ` ] [ fromselector ] .
100102There is no default export.
101103
102- ### ` fromSelector([ selector] [, options]) `
104+ ### ` fromSelector(selector? [, options|space ]) `
103105
104- Create one or more [ * element * ] [ element ] s from a CSS selector.
106+ Create one or more [ ` Element ` ] [ element ] s from a CSS selector.
105107
106108###### Parameters
107109
108110* ` selector ` (` string ` , optional)
109111 — CSS selector
110- * ` space ` (` string ` , optional)
112+ * ` options ` ([ ` Options ` ] [ options ] , optional)
113+ — configuration
114+ * ` space ` ([ ` Space ` ] [ space ] , optional)
111115 — 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)
113128 — which space first element in the selector is in.
114129 When an ` svg ` element is created in HTML, the space is automatically
115130 switched to SVG
116131
117- ###### Returns
132+ ### ` Space `
118133
119- [ ` Element ` ] [ element ] .
134+ Name of namespace (TypeScript type).
135+
136+ ###### Type
137+
138+ ``` ts
139+ type Space = ' html' | ' svg'
140+ ` ` `
120141
121142## Support
122143
@@ -134,19 +155,20 @@ Create one or more [*element*][element]s from a CSS selector.
134155## Types
135156
136157This 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] .
138159
139160## Compatibility
140161
141162Projects maintained by the unified collective are compatible with all maintained
142163versions 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+.
144165Our projects sometimes work with older versions, but this is not guaranteed.
145166
146167## Security
147168
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.
150172
151173Either do not use user input in ` from -selector ` or use
152174[ ` hast -util -santize ` ][hast-util-sanitize].
@@ -229,3 +251,9 @@ abide by its terms.
229251[hast-util-parse-selector]: https://github.com/syntax-tree/hast-util-parse-selector
230252
231253[hastscript]: https://github.com/syntax-tree/hastscript
254+
255+ [fromselector]: #fromselectorselector-optionsspace
256+
257+ [options]: #options
258+
259+ [space]: #space
0 commit comments