@screeb/rrweb 1.0.3 → 1.0.5

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
@@ -1386,41 +1386,8 @@ const pseudoClassPlugin = {
1386
1386
  }
1387
1387
  fixed.push(rule2);
1388
1388
  rule2.selectors.forEach(function(selector) {
1389
- if (!selector.includes(":")) {
1390
- return;
1391
- }
1392
- const selectorParts = selector.replace(/\n/g, " ").split(" ");
1393
- const pseudoedSelectorParts = [];
1394
- selectorParts.forEach(function(selectorPart) {
1395
- const pseudos = selectorPart.match(/::?([^:]+)/g);
1396
- if (!pseudos) {
1397
- pseudoedSelectorParts.push(selectorPart);
1398
- return;
1399
- }
1400
- const baseSelector = selectorPart.substr(
1401
- 0,
1402
- selectorPart.length - pseudos.join("").length
1403
- );
1404
- const classPseudos = pseudos.map(function(pseudo) {
1405
- const pseudoToCheck = pseudo.replace(/\(.*/g, "");
1406
- if (pseudoToCheck !== ":hover") {
1407
- return pseudo;
1408
- }
1409
- if (pseudo.match(/^::/)) {
1410
- return pseudo;
1411
- }
1412
- pseudo = pseudo.substr(1);
1413
- pseudo = pseudo.replace(/\(/g, "\\(");
1414
- pseudo = pseudo.replace(/\)/g, "\\)");
1415
- return ".\\:" + pseudo;
1416
- });
1417
- pseudoedSelectorParts.push(baseSelector + classPseudos.join(""));
1418
- });
1419
- addSelector(pseudoedSelectorParts.join(" "));
1420
- function addSelector(newSelector) {
1421
- if (newSelector && newSelector !== selector) {
1422
- rule2.selector += ",\n" + newSelector;
1423
- }
1389
+ if (selector.includes(":hover")) {
1390
+ rule2.selector += ",\n" + selector.replace(/:hover/g, ".\\:hover");
1424
1391
  }
1425
1392
  });
1426
1393
  }
@@ -5176,9 +5143,9 @@ function buildNode(n2, options) {
5176
5143
  }
5177
5144
  }
5178
5145
  if (name === "rr_width") {
5179
- node2.style.width = value.toString();
5146
+ node2.style.setProperty("width", value.toString());
5180
5147
  } else if (name === "rr_height") {
5181
- node2.style.height = value.toString();
5148
+ node2.style.setProperty("height", value.toString());
5182
5149
  } else if (name === "rr_mediaCurrentTime" && typeof value === "number") {
5183
5150
  node2.currentTime = value;
5184
5151
  } else if (name === "rr_mediaState") {
@@ -9737,7 +9704,13 @@ function diffProps(oldTree, newTree, rrnodeMirror) {
9737
9704
  }
9738
9705
  };
9739
9706
  } else if (newTree.tagName === "IFRAME" && name === "srcdoc") continue;
9740
- else oldTree.setAttribute(name, newValue);
9707
+ else {
9708
+ try {
9709
+ oldTree.setAttribute(name, newValue);
9710
+ } catch (err) {
9711
+ console.warn(err);
9712
+ }
9713
+ }
9741
9714
  }
9742
9715
  for (const { name } of Array.from(oldAttributes))
9743
9716
  if (!(name in newAttributes)) oldTree.removeAttribute(name);
@@ -10973,6 +10946,7 @@ class MutationBuffer {
10973
10946
  __publicField(this, "addedSet", /* @__PURE__ */ new Set());
10974
10947
  __publicField(this, "movedSet", /* @__PURE__ */ new Set());
10975
10948
  __publicField(this, "droppedSet", /* @__PURE__ */ new Set());
10949
+ __publicField(this, "removesSubTreeCache", /* @__PURE__ */ new Set());
10976
10950
  __publicField(this, "mutationCb");
10977
10951
  __publicField(this, "blockClass");
10978
10952
  __publicField(this, "blockSelector");
@@ -11086,13 +11060,13 @@ class MutationBuffer {
11086
11060
  this.mirror.removeNodeFromMap(this.mapRemoves.shift());
11087
11061
  }
11088
11062
  for (const n2 of this.movedSet) {
11089
- if (isParentRemoved(this.removes, n2, this.mirror) && !this.movedSet.has(index.parentNode(n2))) {
11063
+ if (isParentRemoved(this.removesSubTreeCache, n2, this.mirror) && !this.movedSet.has(index.parentNode(n2))) {
11090
11064
  continue;
11091
11065
  }
11092
11066
  pushAdd(n2);
11093
11067
  }
11094
11068
  for (const n2 of this.addedSet) {
11095
- if (!isAncestorInSet(this.droppedSet, n2) && !isParentRemoved(this.removes, n2, this.mirror)) {
11069
+ if (!isAncestorInSet(this.droppedSet, n2) && !isParentRemoved(this.removesSubTreeCache, n2, this.mirror)) {
11096
11070
  pushAdd(n2);
11097
11071
  } else if (isAncestorInSet(this.movedSet, n2)) {
11098
11072
  pushAdd(n2);
@@ -11188,6 +11162,7 @@ class MutationBuffer {
11188
11162
  this.addedSet = /* @__PURE__ */ new Set();
11189
11163
  this.movedSet = /* @__PURE__ */ new Set();
11190
11164
  this.droppedSet = /* @__PURE__ */ new Set();
11165
+ this.removesSubTreeCache = /* @__PURE__ */ new Set();
11191
11166
  this.movedMap = {};
11192
11167
  this.mutationCb(payload);
11193
11168
  });
@@ -11342,6 +11317,7 @@ class MutationBuffer {
11342
11317
  id: nodeId,
11343
11318
  isShadow: isShadowRoot(m.target) && isNativeShadowDom(m.target) ? true : void 0
11344
11319
  });
11320
+ processRemoves(n2, this.removesSubTreeCache);
11345
11321
  }
11346
11322
  this.mapRemoves.push(n2);
11347
11323
  });
@@ -11439,20 +11415,24 @@ function deepDelete(addsSet, n2) {
11439
11415
  addsSet.delete(n2);
11440
11416
  index.childNodes(n2).forEach((childN) => deepDelete(addsSet, childN));
11441
11417
  }
11442
- function isParentRemoved(removes, n2, mirror2) {
11443
- if (removes.length === 0) return false;
11444
- return _isParentRemoved(removes, n2, mirror2);
11445
- }
11446
- function _isParentRemoved(removes, n2, mirror2) {
11447
- let node2 = index.parentNode(n2);
11448
- while (node2) {
11449
- const parentId = mirror2.getId(node2);
11450
- if (removes.some((r2) => r2.id === parentId)) {
11451
- return true;
11452
- }
11453
- node2 = index.parentNode(node2);
11418
+ function processRemoves(n2, cache) {
11419
+ const queue = [n2];
11420
+ while (queue.length) {
11421
+ const next = queue.pop();
11422
+ if (cache.has(next)) continue;
11423
+ cache.add(next);
11424
+ index.childNodes(next).forEach((n22) => queue.push(n22));
11454
11425
  }
11455
- return false;
11426
+ return;
11427
+ }
11428
+ function isParentRemoved(removes, n2, mirror2) {
11429
+ if (removes.size === 0) return false;
11430
+ return _isParentRemoved(removes, n2);
11431
+ }
11432
+ function _isParentRemoved(removes, n2, _mirror) {
11433
+ const node2 = index.parentNode(n2);
11434
+ if (!node2) return false;
11435
+ return removes.has(node2);
11456
11436
  }
11457
11437
  function isAncestorInSet(set, n2) {
11458
11438
  if (set.size === 0) return false;
@@ -11718,14 +11698,14 @@ function initScrollObserver({
11718
11698
  );
11719
11699
  return on("scroll", updatePosition, doc);
11720
11700
  }
11721
- function initViewportResizeObserver({ viewportResizeCb }, { win }) {
11701
+ function initViewportResizeObserver({ viewportResizeCb, win: _win }, { win }) {
11722
11702
  let lastH = -1;
11723
11703
  let lastW = -1;
11724
11704
  const updateDimension = callbackWrapper(
11725
11705
  throttle(
11726
11706
  callbackWrapper(() => {
11727
- const height = getWindowHeight(win);
11728
- const width = getWindowWidth(win);
11707
+ const height = getWindowHeight(_win);
11708
+ const width = getWindowWidth(_win);
11729
11709
  if (lastH !== height || lastW !== width) {
11730
11710
  viewportResizeCb({
11731
11711
  width: Number(width),