choojs / nanomorph

🚅 - Hyper fast diffing algorithm for real DOM nodes
MIT License
726 stars 58 forks source link

test attribute copying #39

Closed yoshuawuyts closed 7 years ago

yoshuawuyts commented 7 years ago

We're testing SVG namespaces and events, but not regular ol' attributes. I've been running into issues on the server with this, so we should probably test this. Would also help enable #37 as we need to read and write attributes.

Specifically it'd be nice if tests could hit el.setAttribute() and el.getAttribute(). Thanks!

yoshuawuyts commented 7 years ago

Had a <div data-something="foo"> and a <div data-something-else="bar">, merged em and the result had both properties. Obv something is not going alright there :(

kristoferjoseph commented 7 years ago

What is the expected behavior in that example? Are you thinking the attribute logic should: see if the attr exists on old but not on new then nuke it see if the attr exists on new and old, then update to the new value if they are not the same

Is there ever a case where you would want to retain the old attrs?

yoshuawuyts commented 7 years ago

Don't think we'd ever wanna retain the old values. From a UX perspective for all intents and purposes it's a new element despite us recycling it

On Wed, Jan 25, 2017, 22:09 kj notifications@github.com wrote:

What is the expected behavior in that example? Are you thinking the attribute logic should: see if the attr exists on old but not on new then nuke it see if the attr exists on new and old, then update to the new value

Is there ever a case where you would want to retain the old attrs?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/yoshuawuyts/nanomorph/issues/39#issuecomment-275314814, or mute the thread https://github.com/notifications/unsubscribe-auth/ACWleg1Wnk4aAzvFCAMMjT-H7K73ewU2ks5rWDitgaJpZM4LrvUV .

kristoferjoseph commented 7 years ago

That was my inclination as well.

I checked the code and it seems to at least logically follow the cases I described above.

Will add some more tests to try and get to the bottom of it.