@@ -459,53 +459,32 @@ function serialize_element_attribute_update_assignment(element, node_id, attribu
459
459
}
460
460
}
461
461
462
- let grouped_value = value ;
463
-
464
462
if ( name === 'autofocus' ) {
465
463
state . init . push ( b . stmt ( b . call ( '$.autofocus' , node_id , value ) ) ) ;
466
464
return false ;
467
465
}
468
466
467
+ /** @type {import('estree').Statement } */
468
+ let update ;
469
+
469
470
if ( name === 'class' ) {
470
- grouped_value = b . call ( '$.to_class' , value ) ;
471
+ update = b . stmt ( b . call ( is_svg ? '$.svg_class_name' : '$.class_name' , node_id , value ) ) ;
472
+ } else if ( DOMProperties . includes ( name ) ) {
473
+ update = b . stmt ( b . assignment ( '=' , b . member ( node_id , b . id ( name ) ) , value ) ) ;
474
+ } else {
475
+ const callee = name . startsWith ( 'xlink' ) ? '$.xlink_attr' : '$.attr' ;
476
+ update = b . stmt ( b . call ( callee , node_id , b . literal ( name ) , value ) ) ;
471
477
}
472
478
473
- /**
474
- * @param {import('estree').Expression } grouped
475
- * @param {import('estree').Expression } [singular]
476
- */
477
- const assign = ( grouped , singular ) => {
478
- if ( name === 'class' ) {
479
- if ( singular ) {
480
- return b . stmt ( b . call ( is_svg ? '$.svg_class_name' : '$.class_name' , node_id , singular ) ) ;
481
- }
482
- return b . stmt ( b . call ( is_svg ? '$.svg_class_name' : '$.class_name' , node_id , value ) ) ;
483
- }
484
-
485
- if ( DOMProperties . includes ( name ) ) {
486
- return b . stmt ( b . assignment ( '=' , b . member ( node_id , b . id ( name ) ) , grouped ) ) ;
487
- }
488
-
489
- return b . stmt (
490
- b . call (
491
- name . startsWith ( 'xlink' ) ? '$.xlink_attr' : '$.attr' ,
492
- node_id ,
493
- b . literal ( name ) ,
494
- grouped
495
- )
496
- ) ;
497
- } ;
498
-
499
479
if ( attribute . metadata . dynamic ) {
500
- const grouped = assign ( grouped_value , value ) ;
501
480
if ( contains_call_expression ) {
502
- state . init . push ( serialize_update ( grouped ) ) ;
481
+ state . init . push ( serialize_update ( update ) ) ;
503
482
} else {
504
- state . update . push ( grouped ) ;
483
+ state . update . push ( update ) ;
505
484
}
506
485
return true ;
507
486
} else {
508
- state . init . push ( assign ( grouped_value ) ) ;
487
+ state . init . push ( update ) ;
509
488
return false ;
510
489
}
511
490
}
0 commit comments