We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When using a hx-swap="delete swap:1s", the target element could have been deleted already.
hx-swap="delete swap:1s"
To reproduce simply do:
<div id="add-users-modal" hx-replace> <button hx-post="/add" hx-target="#add-users-modal" hx-swap="delete swap:1s" @htmx:after-request="show=false" type="button" >add<button> </div> <script> document.addEventListener("htmx:beforeSwap", (event) => { const content = event.detail.serverResponse; if (content.includes("hx-replace")) { const parser = new DOMParser(); const doc = parser.parseFromString(content, "text/html"); const id = doc.querySelector("[hx-replace]").id; const el = event.detail.target.querySelector(`#${id}`); if (el) { el.remove(); } } }); <script>
Here hx-replace is an attribute I defined myself to replace if present else append.
hx-replace
In such use cases, I'll get htmx.esm.js:1699 Uncaught TypeError: Cannot read properties of null (reading 'removeChild')
htmx.esm.js:1699 Uncaught TypeError: Cannot read properties of null (reading 'removeChild')
The text was updated successfully, but these errors were encountered:
fix bigskysoftware#2932: check parent is null for swap delete
b6d93eb
158ea78
fix bigskysoftware#2932: check parent is null for swap
857f99a
fix #2932: check parent is null for swap delete (#2933)
4916ce4
* fix #2932: check parent is null for swap * fix test in swap when parent elt deleted
Successfully merging a pull request may close this issue.
When using a
hx-swap="delete swap:1s"
, the target element could have been deleted already.To reproduce simply do:
Here
hx-replace
is an attribute I defined myself to replace if present else append.In such use cases, I'll get
htmx.esm.js:1699 Uncaught TypeError: Cannot read properties of null (reading 'removeChild')
The text was updated successfully, but these errors were encountered: