@@ -444,15 +444,14 @@ function serialize_element_attribute_update_assignment(element, node_id, attribu
444
444
445
445
// The foreign namespace doesn't have any special handling, everything goes through the attr function
446
446
if ( context . state . metadata . namespace === 'foreign' ) {
447
- const statement = {
448
- grouped : b . stmt ( b . call ( '$.set_attribute' , node_id , b . literal ( name ) , value ) )
449
- } ;
447
+ const statement = b . stmt ( b . call ( '$.set_attribute' , node_id , b . literal ( name ) , value ) ) ;
448
+
450
449
if ( attribute . metadata . dynamic ) {
451
450
const id = state . scope . generate ( `${ node_id . name } _${ name } ` ) ;
452
- serialize_update_assignment ( state , id , undefined , value , statement , contains_call_expression ) ;
451
+ serialize_update_assignment ( state , id , undefined , value , statement ) ;
453
452
return true ;
454
453
} else {
455
- state . init . push ( statement . grouped ) ;
454
+ state . init . push ( statement ) ;
456
455
return false ;
457
456
}
458
457
}
@@ -526,7 +525,7 @@ function serialize_custom_element_attribute_update_assignment(node_id, attribute
526
525
*/
527
526
function serialize_element_special_value_attribute ( element , node_id , attribute , context ) {
528
527
const state = context . state ;
529
- const [ contains_call_expression , value ] = serialize_attribute_value ( attribute . value , context ) ;
528
+ const [ , value ] = serialize_attribute_value ( attribute . value , context ) ;
530
529
531
530
const inner_assignment = b . assignment (
532
531
'=' ,
@@ -542,7 +541,8 @@ function serialize_element_special_value_attribute(element, node_id, attribute,
542
541
// attribute.metadata.dynamic would give false negatives because even if the value does not change,
543
542
// the inner options could still change, so we need to always treat it as reactive
544
543
element === 'select' && attribute . value !== true && ! is_text_attribute ( attribute ) ;
545
- const assignment = b . stmt (
544
+
545
+ const update = b . stmt (
546
546
is_select_with_value
547
547
? b . sequence ( [
548
548
inner_assignment ,
@@ -561,17 +561,10 @@ function serialize_element_special_value_attribute(element, node_id, attribute,
561
561
562
562
if ( is_reactive ) {
563
563
const id = state . scope . generate ( `${ node_id . name } _value` ) ;
564
- serialize_update_assignment (
565
- state ,
566
- id ,
567
- undefined ,
568
- value ,
569
- { grouped : assignment } ,
570
- contains_call_expression
571
- ) ;
564
+ serialize_update_assignment ( state , id , undefined , value , update ) ;
572
565
return true ;
573
566
} else {
574
- state . init . push ( assignment ) ;
567
+ state . init . push ( update ) ;
575
568
return false ;
576
569
}
577
570
}
@@ -581,39 +574,13 @@ function serialize_element_special_value_attribute(element, node_id, attribute,
581
574
* @param {string } id
582
575
* @param {import('estree').Expression | undefined } init
583
576
* @param {import('estree').Expression } value
584
- * @param {{
585
- * grouped: import('estree').ExpressionStatement;
586
- * singular?: import('estree').ExpressionStatement;
587
- * skip_condition?: boolean;
588
- * }} assignment
589
- * @param {boolean } contains_call_expression
577
+ * @param {import('estree').ExpressionStatement } update
590
578
*/
591
- function serialize_update_assignment ( state , id , init , value , assignment , contains_call_expression ) {
592
- const grouped = b . if (
593
- b . binary ( '!==' , b . id ( id ) , b . assignment ( '=' , b . id ( id ) , value ) ) ,
594
- b . block ( [ assignment . grouped ] )
579
+ function serialize_update_assignment ( state , id , init , value , update ) {
580
+ state . init . push ( b . var ( id , init ) ) ;
581
+ state . update . push (
582
+ b . if ( b . binary ( '!==' , b . id ( id ) , b . assignment ( '=' , b . id ( id ) , value ) ) , b . block ( [ update ] ) )
595
583
) ;
596
-
597
- if ( contains_call_expression && assignment . singular ) {
598
- state . init . push ( assignment . singular ) ;
599
- } else {
600
- if ( assignment . skip_condition ) {
601
- if ( assignment . singular ) {
602
- state . update . push ( assignment . grouped ) ;
603
- } else {
604
- state . init . push ( b . var ( id , init ) ) ;
605
- state . update . push ( grouped ) ;
606
- }
607
- } else {
608
- if ( assignment . singular ) {
609
- state . init . push ( b . var ( id , init ) ) ;
610
- state . update . push ( grouped ) ;
611
- } else {
612
- state . init . push ( b . var ( id , init ) ) ;
613
- state . update . push ( grouped ) ;
614
- }
615
- }
616
- }
617
584
}
618
585
619
586
/**
0 commit comments