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:
@@ -93,6 +93,9 @@ export class CookieBannerClient {
|
|||||||
config = await fetchJSON<BannerConfig>(configUrl);
|
config = await fetchJSON<BannerConfig>(configUrl);
|
||||||
} catch {
|
} catch {
|
||||||
this.startDetector();
|
this.startDetector();
|
||||||
|
if (this.observer) {
|
||||||
|
this.observer.disconnect();
|
||||||
|
}
|
||||||
this.observer = observeAndActivate({}, {});
|
this.observer = observeAndActivate({}, {});
|
||||||
getConsent()._setReady({}, false);
|
getConsent()._setReady({}, false);
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user