@@ -444,15 +444,14 @@ function serialize_element_attribute_update_assignment(element, node_id, attribu
444444
445445 // The foreign namespace doesn't have any special handling, everything goes through the attr function
446446 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+
450449 if ( attribute . metadata . dynamic ) {
451450 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 ) ;
453452 return true ;
454453 } else {
455- state . init . push ( statement . grouped ) ;
454+ state . init . push ( statement ) ;
456455 return false ;
457456 }
458457 }
@@ -526,7 +525,7 @@ function serialize_custom_element_attribute_update_assignment(node_id, attribute
526525 */
527526function serialize_element_special_value_attribute ( element , node_id , attribute , context ) {
528527 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 ) ;
530529
531530 const inner_assignment = b . assignment (
532531 '=' ,
@@ -542,7 +541,8 @@ function serialize_element_special_value_attribute(element, node_id, attribute,
542541 // attribute.metadata.dynamic would give false negatives because even if the value does not change,
543542 // the inner options could still change, so we need to always treat it as reactive
544543 element === 'select' && attribute . value !== true && ! is_text_attribute ( attribute ) ;
545- const assignment = b . stmt (
544+
545+ const update = b . stmt (
546546 is_select_with_value
547547 ? b . sequence ( [
548548 inner_assignment ,
@@ -561,17 +561,10 @@ function serialize_element_special_value_attribute(element, node_id, attribute,
561561
562562 if ( is_reactive ) {
563563 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 ) ;
572565 return true ;
573566 } else {
574- state . init . push ( assignment ) ;
567+ state . init . push ( update ) ;
575568 return false ;
576569 }
577570}
@@ -581,39 +574,13 @@ function serialize_element_special_value_attribute(element, node_id, attribute,
581574 * @param {string } id
582575 * @param {import('estree').Expression | undefined } init
583576 * @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
590578 */
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 ] ) )
595583 ) ;
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- }
617584}
618585
619586/**
0 commit comments