From 1561a7daa29c142ff8c092bdcf107999bfdc978a Mon Sep 17 00:00:00 2001 From: Vincent Date: Fri, 30 Jun 2023 18:25:37 +0200 Subject: [PATCH] Fix sse listener removal if element isn't in body anymore (#1484) --- src/htmx.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/htmx.js b/src/htmx.js index b2f9b54d2..1ea5dac57 100644 --- a/src/htmx.js +++ b/src/htmx.js @@ -1664,6 +1664,9 @@ return (function () { var sseEventSource = getInternalData(sseSourceElt).sseEventSource; var sseListener = function (event) { if (maybeCloseSSESource(sseSourceElt)) { + return; + } + if (!bodyContains(elt)) { sseEventSource.removeEventListener(sseEventName, sseListener); return; }