@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.
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) => {
@@ -14681,9 +14689,12 @@ function record(options = {}) {
14681
14689
  }
14682
14690
  };
14683
14691
  const wrappedMutationEmit = (m) => {
14684
- 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;
14685
14694
  m.removes.forEach(({ id }) => {
14686
- iframeManager.removeIframeById(id);
14695
+ if (!addedIds || !addedIds.has(id)) {
14696
+ iframeManager.removeIframeById(id);
14697
+ }
14687
14698
  });
14688
14699
  }
14689
14700
  wrappedEmit({