purescript-halogen-vdom icon indicating copy to clipboard operation
purescript-halogen-vdom copied to clipboard

why diffProp function gets most recent property value on "value" update?

Open srghma opened this issue 5 years ago • 4 comments
trafficstars

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)

srghma avatar May 15 '20 16:05 srghma

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

natefaubion avatar May 15 '20 16:05 natefaubion

snabbdom does this only for value, elm does this for value and checked

why elm does this for checked too?

srghma avatar May 15 '20 16:05 srghma

I don't know the answer to that. I've never had issues with checked. You could maybe follow the blame for that code.

natefaubion avatar May 15 '20 16:05 natefaubion

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

srghma avatar May 15 '20 17:05 srghma