Value needs to be able to be checked against current value during morph
In Datastar you can do 2 way binding of inputs/select/textarea/etc. The incoming morphs may not have there value's set and idiomorph is treating that as a clearing of the value.
Per a conversation with @botandrose we need more detail in attributeChangedCallback. Specifically access to the target/incomings element, attrtibute name and possibly values if they are already in memory.
Taking inspiration from Web Components, (attrName:string, oldValue:T, newValue:T, targetEl:Element, incomingEl:Element) seems to be a decent signature for the callback.
We discussed this issue briefly and it may be possible to instead use the beforeNodeMorphed(oldNode, newNode) callback instead and by checking the data-* attributes impacted during this callback you may be able to read and update the oldNode or newNode values and tweak them before it moves down to the next morphAttribute() step so you can get the result you want.
I think it may also be possible to change
beforeAttributeUpdated(attributeName, node, mutationType) callback to
beforeAttributeUpdated(attributeName, oldNode, mutationType, newNode)
I think this would still work with any existing callback implementations because they would ignore the extra 4th Element argument being passed in so it wouldn't be a big breaking change. renaming node to oldNode should also be possible maybe because the argument name is kind of internal only.
Can confirm, was able to fix with beforeNodeMorph. I'll leave open if you decide to extend the attribute callback