@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.
@@ -11835,14 +11835,22 @@ class IframeManager {
11835
11835
  }
11836
11836
  removeIframeById(iframeId) {
11837
11837
  const entry = this.attachedIframes.get(iframeId);
11838
- if (!entry) return;
11839
- const win = entry.element.contentWindow;
11840
- if (win && this.nestedIframeListeners.has(win)) {
11841
- const handler = this.nestedIframeListeners.get(win);
11842
- win.removeEventListener("message", handler);
11843
- this.nestedIframeListeners.delete(win);
11838
+ const iframe = (entry == null ? void 0 : entry.element) || this.mirror.getNode(iframeId);
11839
+ if (iframe) {
11840
+ const win = iframe.contentWindow;
11841
+ if (win && this.nestedIframeListeners.has(win)) {
11842
+ const handler = this.nestedIframeListeners.get(win);
11843
+ win.removeEventListener("message", handler);
11844
+ this.nestedIframeListeners.delete(win);
11845
+ }
11846
+ if (win) {
11847
+ this.crossOriginIframeMap.delete(win);
11848
+ }
11849
+ this.iframes.delete(iframe);
11850
+ }
11851
+ if (entry) {
11852
+ this.attachedIframes.delete(iframeId);
11844
11853
  }
11845
- this.attachedIframes.delete(iframeId);
11846
11854
  }
11847
11855
  reattachIframes() {
11848
11856
  this.attachedIframes.forEach(({ content }, iframeId) => {
@@ -12808,9 +12816,12 @@ function record(options = {}) {
12808
12816
  }
12809
12817
  };
12810
12818
  const wrappedMutationEmit = (m) => {
12811
- if (recordCrossOriginIframes && m.removes) {
12819
+ if (recordCrossOriginIframes && m.removes && m.removes.length > 0) {
12820
+ const addedIds = m.adds.length > 0 ? new Set(m.adds.map((add) => add.node.id)) : null;
12812
12821
  m.removes.forEach(({ id }) => {
12813
- iframeManager.removeIframeById(id);
12822
+ if (!addedIds || !addedIds.has(id)) {
12823
+ iframeManager.removeIframeById(id);
12824
+ }
12814
12825
  });
12815
12826
  }
12816
12827
  wrappedEmit({