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