fix(cookie-banner): disconnect observer in load() error path

When fetchJSON failed, load() unconditionally overwrote this.observer
with a fresh MutationObserver, leaving any previous one observing the
DOM. Repeated load() calls that hit the catch branch leaked one
observer per call. Mirror the disconnect-first pattern already used in
activate().

Signed-off-by: Émile Ré <emile@probo.com>
This commit is contained in:
Émile Ré
2026-05-26 12:07:30 +02:00
parent d181fbe386
commit bd5c527548

View File

@@ -93,6 +93,9 @@ export class CookieBannerClient {
config = await fetchJSON<BannerConfig>(configUrl);
} catch {
this.startDetector();
if (this.observer) {
this.observer.disconnect();
}
this.observer = observeAndActivate({}, {});
getConsent()._setReady({}, false);
return;