@posthog/rrweb 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.
@@ -13694,14 +13694,22 @@ class IframeManager {
13694
13694
  }
13695
13695
  removeIframeById(iframeId) {
13696
13696
  const entry = this.attachedIframes.get(iframeId);
13697
- if (!entry) return;
13698
- const win = entry.element.contentWindow;
13699
- if (win && this.nestedIframeListeners.has(win)) {
13700
- const handler = this.nestedIframeListeners.get(win);
13701
- win.removeEventListener("message", handler);
13702
- this.nestedIframeListeners.delete(win);
13697
+ const iframe = (entry == null ? void 0 : entry.element) || this.mirror.getNode(iframeId);
13698
+ if (iframe) {
13699
+ const win = iframe.contentWindow;
13700
+ if (win && this.nestedIframeListeners.has(win)) {
13701
+ const handler = this.nestedIframeListeners.get(win);
13702
+ win.removeEventListener("message", handler);
13703
+ this.nestedIframeListeners.delete(win);
13704
+ }
13705
+ if (win) {
13706
+ this.crossOriginIframeMap.delete(win);
13707
+ }
13708
+ this.iframes.delete(iframe);
13709
+ }
13710
+ if (entry) {
13711
+ this.attachedIframes.delete(iframeId);
13703
13712
  }
13704
- this.attachedIframes.delete(iframeId);
13705
13713
  }
13706
13714
  reattachIframes() {
13707
13715
  this.attachedIframes.forEach(({ content }, iframeId) => {
@@ -13735,6 +13743,9 @@ class IframeManager {
13735
13743
  this.crossOriginIframeMirror.reset();
13736
13744
  this.crossOriginIframeStyleMirror.reset();
13737
13745
  this.attachedIframes.clear();
13746
+ this.crossOriginIframeMap = /* @__PURE__ */ new WeakMap();
13747
+ this.iframes = /* @__PURE__ */ new WeakMap();
13748
+ this.crossOriginIframeRootIdMap = /* @__PURE__ */ new WeakMap();
13738
13749
  }
13739
13750
  }
13740
13751
  class ShadowDomManager {
@@ -14684,9 +14695,12 @@ function record(options = {}) {
14684
14695
  }
14685
14696
  };
14686
14697
  const wrappedMutationEmit = (m) => {
14687
- if (recordCrossOriginIframes && m.removes) {
14698
+ if (recordCrossOriginIframes && m.removes && m.removes.length > 0) {
14699
+ const addedIds = m.adds.length > 0 ? new Set(m.adds.map((add) => add.node.id)) : null;
14688
14700
  m.removes.forEach(({ id }) => {
14689
- iframeManager.removeIframeById(id);
14701
+ if (!addedIds || !addedIds.has(id)) {
14702
+ iframeManager.removeIframeById(id);
14703
+ }
14690
14704
  });
14691
14705
  }
14692
14706
  wrappedEmit({