Replies: 2 comments 10 replies
-
I do not understand this. If you pass in a value ( A simple example showing this. The only case in which this might not hold is when you try to assign a value that is invalid for the given property. The value will then be forced to the correct format or be ignored. |
Beta Was this translation helpful? Give feedback.
-
This is not quite true. Using |
Beta Was this translation helpful? Give feedback.
-
I'm really excited to hear your thoughts on this—whether you agree or disagree and why.
Svelte offers a declarative approach to describing the UI. For example, we write:
From this, I deduce that the innerHTML of this
<p>
element always matches the value of thetext
variable. Similarly, we can write:This tells me that the innerHTML of the
<p>
element always matches thetext
variable's value, and the class attribute will consistently reflect whatever thesomeClasses
variable contains. The class attribute only changes if, and only if,someClasses
changes. It's very straightforward.I believe this principle should apply to all attributes. For instance, let's consider the value attribute:
Upon reading this, I would conclude that the checked status always reflects whatever
hardCodedFalse
holds. If, for any reason, it changes, then the checked attribute should also change (similar to the class attribute, etc.). This is not how it is handled right now, checkout this repl to see what I mean.This logic should hold unless I explicitly bind the value to that variable:
Even then, I would say that the checked attribute should always reflect whatever value
checkBoxValue
holds, but now, this input can also modify its value.Implementing this would be a breaking change, but could it be worth it?
I'm eager to hear your thoughts on this!
Beta Was this translation helpful? Give feedback.
All reactions