@posthog/rrweb-record 0.0.36 → 0.0.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11805,14 +11805,22 @@ class IframeManager {
11805
11805
  }
11806
11806
  removeIframeById(iframeId) {
11807
11807
  const entry = this.attachedIframes.get(iframeId);
11808
- if (!entry) return;
11809
- const win = entry.element.contentWindow;
11810
- if (win && this.nestedIframeListeners.has(win)) {
11811
- const handler = this.nestedIframeListeners.get(win);
11812
- win.removeEventListener("message", handler);
11813
- this.nestedIframeListeners.delete(win);
11808
+ const iframe = (entry == null ? void 0 : entry.element) || this.mirror.getNode(iframeId);
11809
+ if (iframe) {
11810
+ const win = iframe.contentWindow;
11811
+ if (win && this.nestedIframeListeners.has(win)) {
11812
+ const handler = this.nestedIframeListeners.get(win);
11813
+ win.removeEventListener("message", handler);
11814
+ this.nestedIframeListeners.delete(win);
11815
+ }
11816
+ if (win) {
11817
+ this.crossOriginIframeMap.delete(win);
11818
+ }
11819
+ this.iframes.delete(iframe);
11820
+ }
11821
+ if (entry) {
11822
+ this.attachedIframes.delete(iframeId);
11814
11823
  }
11815
- this.attachedIframes.delete(iframeId);
11816
11824
  }
11817
11825
  reattachIframes() {
11818
11826
  this.attachedIframes.forEach(({ content }, iframeId) => {
@@ -12781,9 +12789,12 @@ function record(options = {}) {
12781
12789
  }
12782
12790
  };
12783
12791
  const wrappedMutationEmit = (m) => {
12784
- if (recordCrossOriginIframes && m.removes) {
12792
+ if (recordCrossOriginIframes && m.removes && m.removes.length > 0) {
12793
+ const addedIds = m.adds.length > 0 ? new Set(m.adds.map((add) => add.node.id)) : null;
12785
12794
  m.removes.forEach(({ id }) => {
12786
- iframeManager.removeIframeById(id);
12795
+ if (!addedIds || !addedIds.has(id)) {
12796
+ iframeManager.removeIframeById(id);
12797
+ }
12787
12798
  });
12788
12799
  }
12789
12800
  wrappedEmit({