@@ -613,10 +613,10 @@ function build_element_attribute_update_assignment(element, node_id, attribute,
613
613
) ;
614
614
}
615
615
616
- const { has_expression_tag , can_inline } =
616
+ const inlinable_expression =
617
617
attribute . value === true
618
- ? { has_expression_tag : false , can_inline : true }
619
- : can_inline_all_nodes (
618
+ ? false // not an expression
619
+ : is_inlinable_expression (
620
620
Array . isArray ( attribute . value ) ? attribute . value : [ attribute . value ] ,
621
621
context . state
622
622
) ;
@@ -628,7 +628,7 @@ function build_element_attribute_update_assignment(element, node_id, attribute,
628
628
}
629
629
return true ;
630
630
} else {
631
- if ( has_expression_tag && can_inline ) {
631
+ if ( inlinable_expression ) {
632
632
push_template_quasi ( context . state , ` ${ name } ="` ) ;
633
633
push_template_expression ( context . state , value ) ;
634
634
push_template_quasi ( context . state , '"' ) ;
@@ -643,23 +643,24 @@ function build_element_attribute_update_assignment(element, node_id, attribute,
643
643
* @param {(AST.Text | AST.ExpressionTag)[] } nodes
644
644
* @param {import('../types.js').ComponentClientTransformState } state
645
645
*/
646
- function can_inline_all_nodes ( nodes , state ) {
647
- let can_inline = true ;
646
+ function is_inlinable_expression ( nodes , state ) {
648
647
let has_expression_tag = false ;
649
648
for ( let value of nodes ) {
650
649
if ( value . type === 'ExpressionTag' ) {
651
650
if ( value . expression . type === 'Identifier' ) {
652
651
const binding = state . scope
653
652
. owner ( value . expression . name )
654
653
?. declarations . get ( value . expression . name ) ;
655
- can_inline &&= can_inline_variable ( binding ) ;
654
+ if ( ! can_inline_variable ( binding ) ) {
655
+ return false ;
656
+ }
656
657
} else {
657
- can_inline = false ;
658
+ return false ;
658
659
}
659
660
has_expression_tag = true ;
660
661
}
661
662
}
662
- return { can_inline , has_expression_tag } ;
663
+ return has_expression_tag ;
663
664
}
664
665
665
666
/**
0 commit comments