@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.
@@ -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) => {
@@ -11844,6 +11852,9 @@ class IframeManager {
11844
11852
  this.crossOriginIframeMirror.reset();
11845
11853
  this.crossOriginIframeStyleMirror.reset();
11846
11854
  this.attachedIframes.clear();
11855
+ this.crossOriginIframeMap = /* @__PURE__ */ new WeakMap();
11856
+ this.iframes = /* @__PURE__ */ new WeakMap();
11857
+ this.crossOriginIframeRootIdMap = /* @__PURE__ */ new WeakMap();
11847
11858
  }
11848
11859
  }
11849
11860
  class ShadowDomManager {
@@ -12776,9 +12787,12 @@ function record(options = {}) {
12776
12787
  }
12777
12788
  };
12778
12789
  const wrappedMutationEmit = (m) => {
12779
- 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;
12780
12792
  m.removes.forEach(({ id }) => {
12781
- iframeManager.removeIframeById(id);
12793
+ if (!addedIds || !addedIds.has(id)) {
12794
+ iframeManager.removeIframeById(id);
12795
+ }
12782
12796
  });
12783
12797
  }
12784
12798
  wrappedEmit({