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);
|
||||
} catch {
|
||||
this.startDetector();
|
||||
if (this.observer) {
|
||||
this.observer.disconnect();
|
||||
}
|
||||
this.observer = observeAndActivate({}, {});
|
||||
getConsent()._setReady({}, false);
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user