From e3f00f73ba9ef5009089bfe53f0d53ac85d1cd29 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Wed, 28 May 2025 17:43:17 -0400 Subject: [PATCH] fix (options are erroneously being marked as valueless --- .../3-transform/server/visitors/shared/element.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/svelte/src/compiler/phases/3-transform/server/visitors/shared/element.js b/packages/svelte/src/compiler/phases/3-transform/server/visitors/shared/element.js index f12a067e94..5aba3e6cf0 100644 --- a/packages/svelte/src/compiler/phases/3-transform/server/visitors/shared/element.js +++ b/packages/svelte/src/compiler/phases/3-transform/server/visitors/shared/element.js @@ -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')); }