I had the weirdest problem with LiveView's change tracking when name attribute has value id

Oh it’s an morphdom issue morphdom vs. named fields

morphdom vs. named fields
<input name="id"> results in the surrounding form being duplicated rather than replaced.
This is because if such a field exists within a form, form.id returns that DOM node rather than the form’s id attribute value.

From GitHub - patrick-steele-idem/morphdom: Fast and lightweight DOM diffing/patching (no virtual DOM needed)

getNodeKey (Function(node)) - Called to get the Node’s unique identifier. This is used by morphdom to rearrange elements rather than creating and destroying an element that already exists. This defaults to using the Node’s id property. (Note that form fields must not have a name corresponding to forms’ DOM properties, e.g. id.)

11 Likes