Open srghma opened 4 years ago
In many browsers, though it may not be the case anymore, setting the input value always resets the cursor position/selection. This avoids setting it if it has not changed so as not to reset the cursor when you are typing. It's a common bit of virtual DOM "lore".
https://github.com/elm/virtual-dom/blob/5a5bcf48720bc7d53461b3cd42a9f19f119c5503/src/Elm/Kernel/VirtualDom.js#L496 https://github.com/snabbdom/snabbdom/blob/ffc166cdb4beae1c800ce2132821baea1c547d6f/src/modules/props.ts#L27
snabbdom does this only for value
, elm does this for value
and checked
why elm does this for checked
too?
I don't know the answer to that. I've never had issues with checked. You could maybe follow the blame for that code.
it comes from this https://github.com/elm/virtual-dom/issues/117
issue
notice the checked False
in this example https://ellie-app.com/qzwpBK5xxMa1
I dont know if this happens in halogen too
here https://github.com/purescript-halogen/purescript-halogen-vdom/blob/8b91e55019060f50779dba20959f47cf4b60678d/src/Halogen/VDom/DOM/Prop.purs#L149-L155
well, I kind of understand why, but still want to know the explanation
the other question is should we update other propNames this way?
for example react calls
value
,checked
,selected
the Controlled attributes and handles them differently (diffHydratedProperties)