@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.
package/dist/rrweb.cjs CHANGED
@@ -13687,14 +13687,22 @@ class IframeManager {
13687
13687
  }
13688
13688
  removeIframeById(iframeId) {
13689
13689
  const entry = this.attachedIframes.get(iframeId);
13690
- if (!entry) return;
13691
- const win = entry.element.contentWindow;
13692
- if (win && this.nestedIframeListeners.has(win)) {
13693
- const handler = this.nestedIframeListeners.get(win);
13694
- win.removeEventListener("message", handler);
13695
- this.nestedIframeListeners.delete(win);
13690
+ const iframe = (entry == null ? void 0 : entry.element) || this.mirror.getNode(iframeId);
13691
+ if (iframe) {
13692
+ const win = iframe.contentWindow;
13693
+ if (win && this.nestedIframeListeners.has(win)) {
13694
+ const handler = this.nestedIframeListeners.get(win);
13695
+ win.removeEventListener("message", handler);
13696
+ this.nestedIframeListeners.delete(win);
13697
+ }
13698
+ if (win) {
13699
+ this.crossOriginIframeMap.delete(win);
13700
+ }
13701
+ this.iframes.delete(iframe);
13702
+ }
13703
+ if (entry) {
13704
+ this.attachedIframes.delete(iframeId);
13696
13705
  }
13697
- this.attachedIframes.delete(iframeId);
13698
13706
  }
13699
13707
  reattachIframes() {
13700
13708
  this.attachedIframes.forEach(({ content }, iframeId) => {
@@ -13728,6 +13736,9 @@ class IframeManager {
13728
13736
  this.crossOriginIframeMirror.reset();
13729
13737
  this.crossOriginIframeStyleMirror.reset();
13730
13738
  this.attachedIframes.clear();
13739
+ this.crossOriginIframeMap = /* @__PURE__ */ new WeakMap();
13740
+ this.iframes = /* @__PURE__ */ new WeakMap();
13741
+ this.crossOriginIframeRootIdMap = /* @__PURE__ */ new WeakMap();
13731
13742
  }
13732
13743
  }
13733
13744
  class ShadowDomManager {
@@ -14680,9 +14691,12 @@ function record(options = {}) {
14680
14691
  }
14681
14692
  };
14682
14693
  const wrappedMutationEmit = (m) => {
14683
- if (recordCrossOriginIframes && m.removes) {
14694
+ if (recordCrossOriginIframes && m.removes && m.removes.length > 0) {
14695
+ const addedIds = m.adds.length > 0 ? new Set(m.adds.map((add) => add.node.id)) : null;
14684
14696
  m.removes.forEach(({ id }) => {
14685
- iframeManager.removeIframeById(id);
14697
+ if (!addedIds || !addedIds.has(id)) {
14698
+ iframeManager.removeIframeById(id);
14699
+ }
14686
14700
  });
14687
14701
  }
14688
14702
  wrappedEmit({