diff --git a/packages/svelte/src/compiler/phases/3-transform/server/visitors/RegularElement.js b/packages/svelte/src/compiler/phases/3-transform/server/visitors/RegularElement.js index 000df4b086..c19e995349 100644 --- a/packages/svelte/src/compiler/phases/3-transform/server/visitors/RegularElement.js +++ b/packages/svelte/src/compiler/phases/3-transform/server/visitors/RegularElement.js @@ -127,7 +127,16 @@ export function RegularElement(node, context) { } } - if (body === null) { + const is_option_with_implicit_value = + node.name === 'option' && + !node.attributes.some( + (attribute) => + attribute.type === 'SpreadAttribute' || + ((attribute.type === 'Attribute' || attribute.type === 'BindDirective') && + attribute.name === 'value') + ); + + if (body === null && !is_option_with_implicit_value) { process_children(trimmed, { ...context, state }); } else { // we need the body if: @@ -137,14 +146,15 @@ export function RegularElement(node, context) { const inner_state = { ...state, template: [], init: [] }; process_children(trimmed, { ...context, state: inner_state }); - if (node.name === 'option') { + if (is_option_with_implicit_value) { // in case of a valueless `