x-model.blur cleanup crashes when element is removed from DOM (regression from #4729) #4738
-
DescriptionPR #4729 (merged Feb 2, 2026) introduced a cleanup callback in the This error crashes the entire DOM morph process, which also prevents Steps to reproduce
Minimal reproduction with Livewire (same applies with pure Alpine <form wire:submit="save">
<select wire:model.live="type">
<option value="a">A</option>
<option value="b">B</option>
</select>
@if ($type === 'a')
<input wire:model.blur="field_a" />
@endif
<button type="submit">Save</button>
</form>When the user switches from type "a" to "b", the Root causeIn if (el.form) {
let syncCallback = () => syncValue({ target: el });
if (!el.form._x_pendingModelUpdates)
el.form._x_pendingModelUpdates = [];
el.form._x_pendingModelUpdates.push(syncCallback);
cleanup(() => el.form._x_pendingModelUpdates.splice(
el.form._x_pendingModelUpdates.indexOf(syncCallback), 1
));
}The Suggested fixCapture the form reference at registration time: if (el.form) {
let form = el.form;
let syncCallback = () => syncValue({ target: el });
if (!form._x_pendingModelUpdates)
form._x_pendingModelUpdates = [];
form._x_pendingModelUpdates.push(syncCallback);
cleanup(() => form._x_pendingModelUpdates.splice(
form._x_pendingModelUpdates.indexOf(syncCallback), 1
));
}Versions
|
Beta Was this translation helpful? Give feedback.
Replies: 5 comments
-
|
I confirm that this issue exists. After applying the @kenlas DOM fix, the form is updated correctly without any errors. |
Beta Was this translation helpful? Give feedback.
-
|
This issue is also affecting a production application I support. |
Beta Was this translation helpful? Give feedback.
-
|
Confirmed. I'm also running into this exact issue. |
Beta Was this translation helpful? Give feedback.
-
|
Confirm. Same issue here |
Beta Was this translation helpful? Give feedback.
-
|
Apologies, I didn’t see this issue. This has been fixed in the latest release. Please upgrade to v3.15.9 |
Beta Was this translation helpful? Give feedback.
Apologies, I didn’t see this issue. This has been fixed in the latest release. Please upgrade to v3.15.9