TypeError: els2 is not iterable thrown in morph keyToMap when a full-page component containing <input> elements re-renders
Livewire version
v4.4.2
Laravel version
v12.0
PHP version
8.4
Browser and operating system
Chrome on MacOs
Describe the issue you're experiencing
Whenever my full-page Livewire component re-renders (such as submitting a form), the client-side DOM morph crashes with Uncaught TypeError: els2 is not iterable. This happens because Alpine's morph algorithm tries to inspect child nodes on elements (void elements with no children) when they have id attributes assigned.
Code snippets to reproduce the issue
Uncaught (in promise) TypeError: els2 is not iterable
at context.keyToMap (livewire.js:14750:22)
at context.patchChildren (livewire.js:14602:30)<form wire:submit="search">
<!-- Notice the id="..." attribute on the input -->
<input type="date" id="check_in" wire:model="check_in" />
<button type="submit">Search</button>
</form>public function search(): void {}
public function render()
{
return view('livewire.search');
}Screenshots/screen recordings
No response
How do you expect it to work?
When I click search the property should displayed without any javascript error, on the issue tab.
Clicking Search triggers TypeError: els2 is not iterable during the DOM morph. Removing id="check_in" prevents the crash.
Temporary Workaround
Adding wire:ignore to the parent <form> avoids the morph crash while preserving wire:model and wire:submit functionality[cite: 1].
Suggested Fix
Guard keyToMap against non-iterable/null inputs or skip patchChildren for void HTML elements (e.g., <input>, <img>, <br>) inside @alpinejs/morph.
Please confirm (incomplete submissions will not be addressed)
- I have provided easy and step-by-step instructions to reproduce the bug.
- I have provided code samples as text and NOT images.
- I understand my bug report will be removed if I haven't met the criteria above.
Source: livewire/livewire