@@ -3256,7 +3256,14 @@ fn parse_jsx_opening_element<'a>(node: &'a JSXOpeningElement, context: &mut Cont
3256
3256
items. extend ( parse_node ( type_args. into ( ) , context) ) ;
3257
3257
}
3258
3258
3259
- if !node. attrs . is_empty ( ) {
3259
+ let single_line_space_at_end = node. self_closing ( ) && space_before_self_closing_tag_slash;
3260
+ if node. attrs . len ( ) == 1 && node. type_args . is_none ( ) && is_jsx_attr_with_string ( & node. attrs [ 0 ] ) {
3261
+ items. push_str ( " " ) ;
3262
+ items. extend ( parse_node ( node. attrs [ 0 ] . into ( ) , context) ) ;
3263
+ if single_line_space_at_end {
3264
+ items. push_str ( " " ) ;
3265
+ }
3266
+ } else if !node. attrs . is_empty ( ) {
3260
3267
items. extend ( parse_separated_values (
3261
3268
ParseSeparatedValuesParams {
3262
3269
nodes : node. attrs . iter ( ) . map ( |p| NodeOrSeparator :: Node ( p. into ( ) ) ) . collect ( ) ,
@@ -3265,7 +3272,7 @@ fn parse_jsx_opening_element<'a>(node: &'a JSXOpeningElement, context: &mut Cont
3265
3272
allow_blank_lines : false ,
3266
3273
separator : Separator :: none ( ) ,
3267
3274
single_line_space_at_start : true ,
3268
- single_line_space_at_end : node . self_closing ( ) && space_before_self_closing_tag_slash ,
3275
+ single_line_space_at_end,
3269
3276
custom_single_line_separator : None ,
3270
3277
multi_line_options : parser_helpers:: MultiLineOptions :: surround_newlines_indented ( ) ,
3271
3278
force_possible_newline_at_start : false ,
@@ -3312,6 +3319,15 @@ fn parse_jsx_opening_element<'a>(node: &'a JSXOpeningElement, context: &mut Cont
3312
3319
false
3313
3320
}
3314
3321
}
3322
+
3323
+ fn is_jsx_attr_with_string ( node : & JSXAttrOrSpread ) -> bool {
3324
+ if let JSXAttrOrSpread :: JSXAttr ( attrib) = node {
3325
+ if let Some ( value) = attrib. value {
3326
+ return value. kind ( ) == NodeKind :: Str ;
3327
+ }
3328
+ }
3329
+ return false ;
3330
+ }
3315
3331
}
3316
3332
3317
3333
fn parse_jsx_opening_fragment < ' a > ( _: & ' a JSXOpeningFragment , _: & mut Context < ' a > ) -> PrintItems {
0 commit comments