@posthog/rrweb 0.0.36 → 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) => {
@@ -14687,9 +14695,12 @@ function record(options = {}) {
14687
14695
  }
14688
14696
  };
14689
14697
  const wrappedMutationEmit = (m) => {
14690
- 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;
14691
14700
  m.removes.forEach(({ id }) => {
14692
- iframeManager.removeIframeById(id);
14701
+ if (!addedIds || !addedIds.has(id)) {
14702
+ iframeManager.removeIframeById(id);
14703
+ }
14693
14704
  });
14694
14705
  }
14695
14706
  wrappedEmit({