@posthog/rrweb-record 0.0.35 → 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) => {
@@ -11876,6 +11884,9 @@ class IframeManager {
11876
11884
  this.crossOriginIframeMirror.reset();
11877
11885
  this.crossOriginIframeStyleMirror.reset();
11878
11886
  this.attachedIframes.clear();
11887
+ this.crossOriginIframeMap = /* @__PURE__ */ new WeakMap();
11888
+ this.iframes = /* @__PURE__ */ new WeakMap();
11889
+ this.crossOriginIframeRootIdMap = /* @__PURE__ */ new WeakMap();
11879
11890
  }
11880
11891
  }
11881
11892
  class ShadowDomManager {
@@ -12805,9 +12816,12 @@ function record(options = {}) {
12805
12816
  }
12806
12817
  };
12807
12818
  const wrappedMutationEmit = (m) => {
12808
- 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;
12809
12821
  m.removes.forEach(({ id }) => {
12810
- iframeManager.removeIframeById(id);
12822
+ if (!addedIds || !addedIds.has(id)) {
12823
+ iframeManager.removeIframeById(id);
12824
+ }
12811
12825
  });
12812
12826
  }
12813
12827
  wrappedEmit({