@@ -242,6 +242,27 @@ fn parse_jsx_opening_element_at<'a, P: Parser<'a>>(
242
242
parse_jsx_opening_element_after_name ( p, start, name) . map ( Either :: Right )
243
243
}
244
244
245
+ #[ inline( always) ]
246
+ fn parse_jsx_attrs < ' a , P : Parser < ' a > > ( p : & mut P ) -> PResult < Vec < JSXAttrOrSpread > > {
247
+ let mut attrs = Vec :: with_capacity ( 8 ) ;
248
+
249
+ while cur ! ( p, false ) . is_ok ( ) {
250
+ trace_cur ! ( p, parse_jsx_opening__attrs_loop) ;
251
+
252
+ if p. input_mut ( )
253
+ . cur ( )
254
+ . is_some_and ( |cur| cur. is_slash ( ) || cur. is_jsx_tag_end ( ) )
255
+ {
256
+ break ;
257
+ }
258
+
259
+ let attr = parse_jsx_attr ( p) ?;
260
+ attrs. push ( attr) ;
261
+ }
262
+
263
+ Ok ( attrs)
264
+ }
265
+
245
266
/// `jsxParseOpeningElementAfterName`
246
267
fn parse_jsx_opening_element_after_name < ' a , P : Parser < ' a > > (
247
268
p : & mut P ,
@@ -256,20 +277,8 @@ fn parse_jsx_opening_element_after_name<'a, P: Parser<'a>>(
256
277
None
257
278
} ;
258
279
259
- let mut attrs = Vec :: new ( ) ;
260
- while cur ! ( p, false ) . is_ok ( ) {
261
- trace_cur ! ( p, parse_jsx_opening__attrs_loop) ;
262
-
263
- if p. input_mut ( )
264
- . cur ( )
265
- . is_some_and ( |cur| cur. is_slash ( ) || cur. is_jsx_tag_end ( ) )
266
- {
267
- break ;
268
- }
280
+ let attrs = parse_jsx_attrs ( p) ?;
269
281
270
- let attr = parse_jsx_attr ( p) ?;
271
- attrs. push ( attr) ;
272
- }
273
282
let self_closing = p. input_mut ( ) . eat ( & P :: Token :: DIV ) ;
274
283
if !p. input_mut ( ) . eat ( & P :: Token :: JSX_TAG_END )
275
284
& !( p. ctx ( ) . contains ( Context :: InForcedJsxContext ) && p. input_mut ( ) . eat ( & P :: Token :: GREATER ) )
0 commit comments