@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.
@@ -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) => {
@@ -11846,6 +11854,9 @@ class IframeManager {
11846
11854
  this.crossOriginIframeMirror.reset();
11847
11855
  this.crossOriginIframeStyleMirror.reset();
11848
11856
  this.attachedIframes.clear();
11857
+ this.crossOriginIframeMap = /* @__PURE__ */ new WeakMap();
11858
+ this.iframes = /* @__PURE__ */ new WeakMap();
11859
+ this.crossOriginIframeRootIdMap = /* @__PURE__ */ new WeakMap();
11849
11860
  }
11850
11861
  }
11851
11862
  class ShadowDomManager {
@@ -12778,9 +12789,12 @@ function record(options = {}) {
12778
12789
  }
12779
12790
  };
12780
12791
  const wrappedMutationEmit = (m) => {
12781
- 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;
12782
12794
  m.removes.forEach(({ id }) => {
12783
- iframeManager.removeIframeById(id);
12795
+ if (!addedIds || !addedIds.has(id)) {
12796
+ iframeManager.removeIframeById(id);
12797
+ }
12784
12798
  });
12785
12799
  }
12786
12800
  wrappedEmit({