_hyperscript
_hyperscript copied to clipboard
Append uses innerHTML
When appending data to the DOM it uses innerHTML. This destroys any htmx or DOM related listeners on existing nodes. Example
on message
append it to the #stream
get the last of the #stream's children then
call htmx.process(it) -- call is required for now, not after next release
end
If multiple messages are received, the htmx behavior of earlier nodes breaks. Perhaps detect the common case of appending a DOM to a DOM and use appendChild internally.
while this works as expected:
on message
make a <tr/>
put event.data into it
put it at the end of the #stream
call htmx.process(it)
end
I ran into this as well. It's quite tricky to debug. In my case form elements would get cleared when I append new elements to the DOM. Ofcourse, using "put at the end of" solves that.
But figuring this out is tricky.
welp, took two years but i fixed it
Yay!