@ -291,7 +291,7 @@ export function RegularElement(node, context) {
const is = is _custom _element
? build _custom _element _attribute _update _assignment ( node _id , attribute , context )
: build _element _attribute _update _assignment ( node , node _id , attribute , context) ;
: build _element _attribute _update _assignment ( node , node _id , attribute , attributes, context) ;
if ( is ) is _attributes _reactive = true ;
}
}
@ -519,10 +519,17 @@ function setup_select_synchronization(value_binding, context) {
* @ param { AST . RegularElement } element
* @ param { Identifier } node _id
* @ param { AST . Attribute } attribute
* @ param { Array < AST . Attribute | AST . SpreadAttribute > } attributes
* @ param { ComponentContext } context
* @ returns { boolean }
* /
function build _element _attribute _update _assignment ( element , node _id , attribute , context ) {
function build _element _attribute _update _assignment (
element ,
node _id ,
attribute ,
attributes ,
context
) {
const state = context . state ;
const name = get _attribute _name ( element , attribute ) ;
const is _svg = context . state . metadata . namespace === 'svg' || element . name === 'svg' ;
@ -565,6 +572,26 @@ function build_element_attribute_update_assignment(element, node_id, attribute,
update = b . stmt ( b . call ( '$.set_checked' , node _id , value ) ) ;
} else if ( name === 'selected' ) {
update = b . stmt ( b . call ( '$.set_selected' , node _id , value ) ) ;
} else if (
// If we would just set the defaultValue property, it would override the value property,
// because it is set in the template which implicitly means it's also setting the default value,
// and if one updates the default value while the input is pristine it will also update the
// current value, which is not what we want, which is why we need to do some extra work.
name === 'defaultValue' &&
( attributes . some (
( attr ) => attr . type === 'Attribute' && attr . name === 'value' && is _text _attribute ( attr )
) ||
( element . name === 'textarea' && element . fragment . nodes . length > 0 ) )
) {
update = b . stmt ( b . call ( '$.set_default_value' , node _id , value ) ) ;
} else if (
// See defaultValue comment
name === 'defaultChecked' &&
attributes . some (
( attr ) => attr . type === 'Attribute' && attr . name === 'checked' && attr . value === true
)
) {
update = b . stmt ( b . call ( '$.set_default_checked' , node _id , value ) ) ;
} else if ( is _dom _property ( name ) ) {
update = b . stmt ( b . assignment ( '=' , b . member ( node _id , name ) , value ) ) ;
} else {