You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, in some cases, this node may already have been removed before the timeout fires and this code errors with:
Uncaught TypeError: Cannot read properties of null (reading 'removeChild')
A use case where this could happen is a flash toast message that also includes a dismiss button/icon (or gesture) and also removes the same node (or a parent) from the DOM.
I suggest to fix this using the Node.prototype.isConnected property within the setTimeout callback. Since IE11 compatibility is required, that would also require the isConnected-polyfill to be added.
The text was updated successfully, but these errors were encountered:
As an alternative, the timeoutID from setTimeout could be stored in the nodes' dataset, so we have a way to cancel the timeout before it fires using clearTimeout, eg:
When the remove-me timeout fires, it will remove the node with the
remove-me
attribute from the DOM, like this:htmx/src/ext/remove-me.js
Line 6 in adfd2c8
However, in some cases, this node may already have been removed before the timeout fires and this code errors with:
A use case where this could happen is a flash toast message that also includes a dismiss button/icon (or gesture) and also removes the same node (or a parent) from the DOM.
I suggest to fix this using the
Node.prototype.isConnected
property within the setTimeout callback. Since IE11 compatibility is required, that would also require the isConnected-polyfill to be added.The text was updated successfully, but these errors were encountered: