fix (options are erroneously being marked as valueless

pull/16017/head
Rich Harris 4 months ago
parent 133a7edb99
commit e3f00f73ba

@ -200,12 +200,15 @@ export function build_element_attributes(node, context) {
}
}
let option_has_value = false;
let is_option_with_implicit_value =
node.name === 'option' &&
!attributes.some(
(attribute) => attribute.type === 'SpreadAttribute' || attribute.name === 'value'
);
if (has_spread) {
build_element_spread_attributes(node, attributes, style_directives, class_directives, context);
if (node.name === 'option') {
option_has_value = true;
context.state.template.push(
b.call(
'$.maybe_selected',
@ -298,13 +301,12 @@ export function build_element_attributes(node, context) {
}
if (name === 'value' && node.name === 'option') {
option_has_value = true;
context.state.template.push(b.call('$.maybe_selected', b.id('$$payload'), value));
}
}
}
if (!option_has_value && node.name === 'option') {
if (is_option_with_implicit_value) {
content = b.call('$.valueless_option', b.id('$$payload'));
}

Loading…
Cancel
Save