@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.
@@ -11803,14 +11803,22 @@ class IframeManager {
11803
11803
  }
11804
11804
  removeIframeById(iframeId) {
11805
11805
  const entry = this.attachedIframes.get(iframeId);
11806
- if (!entry) return;
11807
- const win = entry.element.contentWindow;
11808
- if (win && this.nestedIframeListeners.has(win)) {
11809
- const handler = this.nestedIframeListeners.get(win);
11810
- win.removeEventListener("message", handler);
11811
- this.nestedIframeListeners.delete(win);
11806
+ const iframe = (entry == null ? void 0 : entry.element) || this.mirror.getNode(iframeId);
11807
+ if (iframe) {
11808
+ const win = iframe.contentWindow;
11809
+ if (win && this.nestedIframeListeners.has(win)) {
11810
+ const handler = this.nestedIframeListeners.get(win);
11811
+ win.removeEventListener("message", handler);
11812
+ this.nestedIframeListeners.delete(win);
11813
+ }
11814
+ if (win) {
11815
+ this.crossOriginIframeMap.delete(win);
11816
+ }
11817
+ this.iframes.delete(iframe);
11818
+ }
11819
+ if (entry) {
11820
+ this.attachedIframes.delete(iframeId);
11812
11821
  }
11813
- this.attachedIframes.delete(iframeId);
11814
11822
  }
11815
11823
  reattachIframes() {
11816
11824
  this.attachedIframes.forEach(({ content }, iframeId) => {
@@ -12779,9 +12787,12 @@ function record(options = {}) {
12779
12787
  }
12780
12788
  };
12781
12789
  const wrappedMutationEmit = (m) => {
12782
- if (recordCrossOriginIframes && m.removes) {
12790
+ if (recordCrossOriginIframes && m.removes && m.removes.length > 0) {
12791
+ const addedIds = m.adds.length > 0 ? new Set(m.adds.map((add) => add.node.id)) : null;
12783
12792
  m.removes.forEach(({ id }) => {
12784
- iframeManager.removeIframeById(id);
12793
+ if (!addedIds || !addedIds.has(id)) {
12794
+ iframeManager.removeIframeById(id);
12795
+ }
12785
12796
  });
12786
12797
  }
12787
12798
  wrappedEmit({