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