Skip to content

"Select Bindings" example: why does line 36 work in a .svelte but not in a plain vanilla .js? #11919

Answered by brunnerh
metaleap asked this question in Q&A
Discussion options

You must be logged in to vote

There is special logic because the value as noted can only be a string.

Svelte stores the value in a separate property __value on the DOM instance.
The generated code in v4 looks like this:

option = element("option");
option.__value = option_value_value = /*question*/ ctx[1];
set_input_value(option, option.__value);

(This is also used for things like radio buttons and checkbox groups.)

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@metaleap
Comment options

Answer selected by metaleap
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants