imacrayon / alpine-ajax

An Alpine.js plugin for building server-powered frontends.
https://alpine-ajax.js.org
MIT License
558 stars 11 forks source link

Bug when target is a tr #47

Closed akxlr closed 7 months ago

akxlr commented 8 months ago

It seems that the current version of alpine-ajax doesn't work if the element to be replaced is a tr.

I believe this is because of this line:

https://github.com/imacrayon/alpine-ajax/blob/f0d0bbb1c3c526707f5fc6fcc796c2184ea29469/src/index.js#L283

Specifically, creating the fragment doesn't work:

document.createRange().createContextualFragment('<tr id="someid"></tr>').getElementById("someid")

return null.

So when we try to update a tr, we get "Target #someid not found in AJAX response."