@@ -400,11 +400,10 @@ export function RegularElement(node, context) {
400400 synthetic_node . end ,
401401 [ synthetic_node ]
402402 ) ;
403- // TODO idk if necessary
404- synthetic_attribute . metadata . synthetic_option_value = true ;
405403 // this node is an `option` that didn't have a `value` attribute, but had
406- // a single-expression child, so we synthesize a value for it
407- build_element_special_value_attribute ( node . name , node_id , synthetic_attribute , context ) ;
404+ // a single-expression child, so we treat the value of that expression as
405+ // the value of the option
406+ build_element_special_value_attribute ( node . name , node_id , synthetic_attribute , context , true ) ;
408407 } else {
409408 for ( const attribute of /** @type {AST.Attribute[] } */ ( attributes ) ) {
410409 if ( attribute . name === 'value' ) {
@@ -646,8 +645,15 @@ function build_custom_element_attribute_update_assignment(node_id, attribute, co
646645 * @param {Identifier } node_id
647646 * @param {AST.Attribute } attribute
648647 * @param {ComponentContext } context
648+ * @param {boolean } [synthetic] - true if this should not sync to the DOM
649649 */
650- function build_element_special_value_attribute ( element , node_id , attribute , context ) {
650+ function build_element_special_value_attribute (
651+ element ,
652+ node_id ,
653+ attribute ,
654+ context ,
655+ synthetic = false
656+ ) {
651657 const state = context . state ;
652658 const is_select_with_value =
653659 // attribute.metadata.dynamic would give false negatives because even if the value does not change,
@@ -661,9 +667,6 @@ function build_element_special_value_attribute(element, node_id, attribute, cont
661667 const evaluated = context . state . scope . evaluate ( value ) ;
662668 const assignment = b . assignment ( '=' , b . member ( node_id , '__value' ) , value ) ;
663669
664- const is_synthetic_option =
665- element === 'option' && attribute . metadata . synthetic_option_value === true ;
666-
667670 const set_value_assignment = b . assignment (
668671 '=' ,
669672 b . member ( node_id , 'value' ) ,
@@ -680,7 +683,7 @@ function build_element_special_value_attribute(element, node_id, attribute, cont
680683 // mutation observer wouldn't notice.
681684 b . call ( '$.select_option' , node_id , value )
682685 ] )
683- : is_synthetic_option
686+ : synthetic
684687 ? assignment
685688 : set_value_assignment
686689 ) ;
0 commit comments