You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feature #250 [Live] Fixing bug where inputs would not re-render if the value changed (weaverryan)
This PR was squashed before being merged into the 2.x branch.
Discussion
----------
[Live] Fixing bug where inputs would not re-render if the value changed
| Q | A
| ------------- | ---
| Bug fix? | yes
| New feature? | no
| Tickets | Fix#144 and Bug E on #102.
| License | MIT
~~NOTE to self: I'm considering reversing this PR as it has some side effects where we lose input values on re-render. That can be solved with `data-live-ignore`, but it may be better to reverse this, and "fix" the original problem by telling the user to add a `data-live-update` attribute (or something like that) where we opt INTO re-rendering. There is basically a situation where we don't know if the user will want a form element to re-render (and update the value) or not. And so, the user needs to choose. The question is, which way should the "default" be.~~
For example, if an input rendered initially empty, then you typed
into it, and, on re-render, the value was set BACK to the original,
the input would *not* update on re-render, and it would be stuck
with the old value.
This was because the old input node and new input node were seen
as identical... and so morphdom didn't bother to update that node.
However, in reality, the value property of the "old" input had
been changed and would no longer match the value "attribute" of the
incoming input. Effectively, the 2 inputs had different values, but
this difference was not caught by the system.
Commits
-------
a27fdd3 [Live] Fixing bug where inputs would not re-render if the value changed
thrownewError('cloneNode() produced incorrect type');
204
-
}
202
+
constclonedElement=cloneHTMLElement(element);
205
203
206
204
thrownewError(`The update() method could not be called for "${clonedElement.outerHTML}": the element must either have a "data-model" or "name" attribute set to the model name.`);
207
205
}
@@ -558,7 +556,18 @@ export default class extends Controller {
0 commit comments