33 * @typedef {import('estree-jsx').JSXClosingElement } JSXClosingElement
44 * @typedef {import('estree-jsx').JSXClosingFragment } JSXClosingFragment
55 * @typedef {import('estree-jsx').JSXElement } JSXElement
6- * @typedef {import('estree-jsx').JSXEmptyExpression } JSXEmptyExpression
76 * @typedef {import('estree-jsx').JSXExpressionContainer } JSXExpressionContainer
87 * @typedef {import('estree-jsx').JSXFragment } JSXFragment
98 * @typedef {import('estree-jsx').JSXIdentifier } JSXIdentifier
1312 * @typedef {import('estree-jsx').JSXOpeningFragment } JSXOpeningFragment
1413 * @typedef {import('estree-jsx').JSXSpreadAttribute } JSXSpreadAttribute
1514 * @typedef {import('estree-jsx').JSXText } JSXText
16- * @typedef {import('./types.js').Handler } Handler
1715 * @typedef {import('./types.js').Generator } Generator
1816 * @typedef {import('./types.js').State } State
1917 */
@@ -41,9 +39,13 @@ export const jsx = {
4139 * `attr={1}`
4240 *
4341 * @this {Generator}
42+ * `astring` generator.
4443 * @param {JSXAttribute } node
44+ * Node to serialize.
4545 * @param {State } state
46+ * Info passed around.
4647 * @returns {void }
48+ * Nothing.
4749 */
4850function JSXAttribute ( node , state ) {
4951 this [ node . name . type ] ( node . name , state )
@@ -67,9 +69,13 @@ function JSXAttribute(node, state) {
6769 * `</div>`
6870 *
6971 * @this {Generator}
72+ * `astring` generator.
7073 * @param {JSXClosingElement } node
74+ * Node to serialize.
7175 * @param {State } state
76+ * Info passed around.
7277 * @returns {void }
78+ * Nothing.
7379 */
7480function JSXClosingElement ( node , state ) {
7581 state . write ( '</' )
@@ -81,9 +87,13 @@ function JSXClosingElement(node, state) {
8187 * `</>`
8288 *
8389 * @this {Generator}
90+ * `astring` generator.
8491 * @param {JSXClosingFragment } node
92+ * Node to serialize.
8593 * @param {State } state
94+ * Info passed around.
8695 * @returns {void }
96+ * Nothing.
8797 */
8898function JSXClosingFragment ( node , state ) {
8999 state . write ( '</>' , node )
@@ -94,9 +104,13 @@ function JSXClosingFragment(node, state) {
94104 * `<div></div>`
95105 *
96106 * @this {Generator}
107+ * `astring` generator.
97108 * @param {JSXElement } node
109+ * Node to serialize.
98110 * @param {State } state
111+ * Info passed around.
99112 * @returns {void }
113+ * Nothing.
100114 */
101115function JSXElement ( node , state ) {
102116 let index = - 1
@@ -126,17 +140,23 @@ function JSXElement(node, state) {
126140 * `{}` (always in a `JSXExpressionContainer`, which does the curlies)
127141 *
128142 * @this {Generator}
143+ * `astring` generator.
129144 * @returns {void }
145+ * Nothing.
130146 */
131147function JSXEmptyExpression ( ) { }
132148
133149/**
134150 * `{expression}`
135151 *
136152 * @this {Generator}
153+ * `astring` generator.
137154 * @param {JSXExpressionContainer } node
155+ * Node to serialize.
138156 * @param {State } state
157+ * Info passed around.
139158 * @returns {void }
159+ * Nothing.
140160 */
141161function JSXExpressionContainer ( node , state ) {
142162 state . write ( '{' )
@@ -148,9 +168,13 @@ function JSXExpressionContainer(node, state) {
148168 * `<></>`
149169 *
150170 * @this {Generator}
171+ * `astring` generator.
151172 * @param {JSXFragment } node
173+ * Node to serialize.
152174 * @param {State } state
175+ * Info passed around.
153176 * @returns {void }
177+ * Nothing.
154178 */
155179function JSXFragment ( node , state ) {
156180 let index = - 1
@@ -178,9 +202,13 @@ function JSXFragment(node, state) {
178202 * `div`
179203 *
180204 * @this {Generator}
205+ * `astring` generator.
181206 * @param {JSXIdentifier } node
207+ * Node to serialize.
182208 * @param {State } state
209+ * Info passed around.
183210 * @returns {void }
211+ * Nothing.
184212 */
185213function JSXIdentifier ( node , state ) {
186214 state . write ( node . name , node )
@@ -190,9 +218,13 @@ function JSXIdentifier(node, state) {
190218 * `member.expression`
191219 *
192220 * @this {Generator}
221+ * `astring` generator.
193222 * @param {JSXMemberExpression } node
223+ * Node to serialize.
194224 * @param {State } state
225+ * Info passed around.
195226 * @returns {void }
227+ * Nothing.
196228 */
197229function JSXMemberExpression ( node , state ) {
198230 this [ node . object . type ] ( node . object , state )
@@ -204,9 +236,13 @@ function JSXMemberExpression(node, state) {
204236 * `ns:name`
205237 *
206238 * @this {Generator}
239+ * `astring` generator.
207240 * @param {JSXNamespacedName } node
241+ * Node to serialize.
208242 * @param {State } state
243+ * Info passed around.
209244 * @returns {void }
245+ * Nothing.
210246 */
211247function JSXNamespacedName ( node , state ) {
212248 this [ node . namespace . type ] ( node . namespace , state )
@@ -218,9 +254,13 @@ function JSXNamespacedName(node, state) {
218254 * `<div>`
219255 *
220256 * @this {Generator}
257+ * `astring` generator.
221258 * @param {JSXOpeningElement } node
259+ * Node to serialize.
222260 * @param {State } state
261+ * Info passed around.
223262 * @returns {void }
263+ * Nothing.
224264 */
225265function JSXOpeningElement ( node , state ) {
226266 let index = - 1
@@ -242,9 +282,13 @@ function JSXOpeningElement(node, state) {
242282 * `<>`
243283 *
244284 * @this {Generator}
285+ * `astring` generator.
245286 * @param {JSXOpeningFragment } node
287+ * Node to serialize.
246288 * @param {State } state
289+ * Info passed around.
247290 * @returns {void }
291+ * Nothing.
248292 */
249293function JSXOpeningFragment ( node , state ) {
250294 state . write ( '<>' , node )
@@ -254,9 +298,13 @@ function JSXOpeningFragment(node, state) {
254298 * `{...argument}`
255299 *
256300 * @this {Generator}
301+ * `astring` generator.
257302 * @param {JSXSpreadAttribute } node
303+ * Node to serialize.
258304 * @param {State } state
305+ * Info passed around.
259306 * @returns {void }
307+ * Nothing.
260308 */
261309function JSXSpreadAttribute ( node , state ) {
262310 state . write ( '{' )
@@ -269,9 +317,13 @@ function JSXSpreadAttribute(node, state) {
269317 * `!`
270318 *
271319 * @this {Generator}
320+ * `astring` generator.
272321 * @param {JSXText } node
322+ * Node to serialize.
273323 * @param {State } state
324+ * Info passed around.
274325 * @returns {void }
326+ * Nothing.
275327 */
276328function JSXText ( node , state ) {
277329 state . write (
@@ -290,6 +342,7 @@ function JSXText(node, state) {
290342
291343/**
292344 * Make sure that character references don’t pop up.
345+ *
293346 * For example, the text `©` should stay that way, and not turn into `©`.
294347 * We could encode all `&` (easy but verbose) or look for actual valid
295348 * references (complex but cleanest output).
@@ -298,7 +351,9 @@ function JSXText(node, state) {
298351 * are for the named references.
299352 *
300353 * @param {string } value
354+ * Value to encode.
301355 * @returns {string }
356+ * Encoded value.
302357 */
303358function encodeJsx ( value ) {
304359 return value . replace ( / & (? = [ # a - z ] ) / gi, '&' )
0 commit comments