dmjio / miso

:ramen: A tasty Haskell front-end framework
https://haskell-miso.org
BSD 3-Clause "New" or "Revised" License
2.19k stars 139 forks source link

Diffing algorithm - newProp with value of zero leads to prop deletion #644

Closed troibe closed 3 years ago

troibe commented 3 years ago

Describe the bug If I'm using anything selection based like tabs or options which has a node with a zero index that node will get deleted. I think the reason lies in line 96. https://github.com/dmjio/miso/blob/69f50b49adbff8217f8b51ae5f47727ee950f204/jsbits/diff.js#L94-L96 If newProp = 0 holds then this check will fail however zero is a valid value for a new prop. I think newProp === undefined is probably the check that comes sematically the closest without deleting props with zero value.

To Reproduce Either run https://github.com/developandplay/material-components-web-miso locally or check out our demo website matiso.dev. Then select the first option as shown in the screenshots below and look at the error in the console.

Expected behavior If a newProp = 0 occurs it should be treated as a prop with valid content.

Screenshots Expected behaviour when selecting the second option. node[c] = newProp; gets executed. image

Unexpected behaviour when selecting the first option. node[c] = ''; gets executed. image

Desktop (please complete the following information):

dmjio commented 3 years ago

Very nice catch.