@screeb/rrweb 1.0.4 → 1.0.6

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
@@ -635,6 +635,21 @@ function needMaskingText(node2, maskTextClass, maskTextSelector, checkAncestors)
635
635
  el = index$1.parentElement(node2);
636
636
  }
637
637
  try {
638
+ if (el.tagName === "INPUT") {
639
+ const autocomplete = el.getAttribute("autocomplete");
640
+ const disallowedAutocompleteValues = [
641
+ "current-password",
642
+ "new-password",
643
+ "cc-number",
644
+ "cc-exp",
645
+ "cc-exp-month",
646
+ "cc-exp-year",
647
+ "cc-csc"
648
+ ];
649
+ if (disallowedAutocompleteValues.includes(autocomplete)) {
650
+ return true;
651
+ }
652
+ }
638
653
  if (typeof maskTextClass === "string") {
639
654
  if (checkAncestors) {
640
655
  if (el.closest(`.${maskTextClass}`)) return true;
@@ -1384,41 +1399,8 @@ const pseudoClassPlugin = {
1384
1399
  }
1385
1400
  fixed.push(rule2);
1386
1401
  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
- }
1402
+ if (selector.includes(":hover")) {
1403
+ rule2.selector += ",\n" + selector.replace(/:hover/g, ".\\:hover");
1422
1404
  }
1423
1405
  });
1424
1406
  }
@@ -5174,9 +5156,9 @@ function buildNode(n2, options) {
5174
5156
  }
5175
5157
  }
5176
5158
  if (name === "rr_width") {
5177
- node2.style.width = value.toString();
5159
+ node2.style.setProperty("width", value.toString());
5178
5160
  } else if (name === "rr_height") {
5179
- node2.style.height = value.toString();
5161
+ node2.style.setProperty("height", value.toString());
5180
5162
  } else if (name === "rr_mediaCurrentTime" && typeof value === "number") {
5181
5163
  node2.currentTime = value;
5182
5164
  } else if (name === "rr_mediaState") {
@@ -9735,7 +9717,13 @@ function diffProps(oldTree, newTree, rrnodeMirror) {
9735
9717
  }
9736
9718
  };
9737
9719
  } else if (newTree.tagName === "IFRAME" && name === "srcdoc") continue;
9738
- else oldTree.setAttribute(name, newValue);
9720
+ else {
9721
+ try {
9722
+ oldTree.setAttribute(name, newValue);
9723
+ } catch (err) {
9724
+ console.warn(err);
9725
+ }
9726
+ }
9739
9727
  }
9740
9728
  for (const { name } of Array.from(oldAttributes))
9741
9729
  if (!(name in newAttributes)) oldTree.removeAttribute(name);
@@ -10971,6 +10959,7 @@ class MutationBuffer {
10971
10959
  __publicField(this, "addedSet", /* @__PURE__ */ new Set());
10972
10960
  __publicField(this, "movedSet", /* @__PURE__ */ new Set());
10973
10961
  __publicField(this, "droppedSet", /* @__PURE__ */ new Set());
10962
+ __publicField(this, "removesSubTreeCache", /* @__PURE__ */ new Set());
10974
10963
  __publicField(this, "mutationCb");
10975
10964
  __publicField(this, "blockClass");
10976
10965
  __publicField(this, "blockSelector");
@@ -11084,13 +11073,13 @@ class MutationBuffer {
11084
11073
  this.mirror.removeNodeFromMap(this.mapRemoves.shift());
11085
11074
  }
11086
11075
  for (const n2 of this.movedSet) {
11087
- if (isParentRemoved(this.removes, n2, this.mirror) && !this.movedSet.has(index.parentNode(n2))) {
11076
+ if (isParentRemoved(this.removesSubTreeCache, n2, this.mirror) && !this.movedSet.has(index.parentNode(n2))) {
11088
11077
  continue;
11089
11078
  }
11090
11079
  pushAdd(n2);
11091
11080
  }
11092
11081
  for (const n2 of this.addedSet) {
11093
- if (!isAncestorInSet(this.droppedSet, n2) && !isParentRemoved(this.removes, n2, this.mirror)) {
11082
+ if (!isAncestorInSet(this.droppedSet, n2) && !isParentRemoved(this.removesSubTreeCache, n2, this.mirror)) {
11094
11083
  pushAdd(n2);
11095
11084
  } else if (isAncestorInSet(this.movedSet, n2)) {
11096
11085
  pushAdd(n2);
@@ -11186,6 +11175,7 @@ class MutationBuffer {
11186
11175
  this.addedSet = /* @__PURE__ */ new Set();
11187
11176
  this.movedSet = /* @__PURE__ */ new Set();
11188
11177
  this.droppedSet = /* @__PURE__ */ new Set();
11178
+ this.removesSubTreeCache = /* @__PURE__ */ new Set();
11189
11179
  this.movedMap = {};
11190
11180
  this.mutationCb(payload);
11191
11181
  });
@@ -11340,6 +11330,7 @@ class MutationBuffer {
11340
11330
  id: nodeId,
11341
11331
  isShadow: isShadowRoot(m.target) && isNativeShadowDom(m.target) ? true : void 0
11342
11332
  });
11333
+ processRemoves(n2, this.removesSubTreeCache);
11343
11334
  }
11344
11335
  this.mapRemoves.push(n2);
11345
11336
  });
@@ -11437,20 +11428,24 @@ function deepDelete(addsSet, n2) {
11437
11428
  addsSet.delete(n2);
11438
11429
  index.childNodes(n2).forEach((childN) => deepDelete(addsSet, childN));
11439
11430
  }
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);
11431
+ function processRemoves(n2, cache) {
11432
+ const queue = [n2];
11433
+ while (queue.length) {
11434
+ const next = queue.pop();
11435
+ if (cache.has(next)) continue;
11436
+ cache.add(next);
11437
+ index.childNodes(next).forEach((n22) => queue.push(n22));
11452
11438
  }
11453
- return false;
11439
+ return;
11440
+ }
11441
+ function isParentRemoved(removes, n2, mirror2) {
11442
+ if (removes.size === 0) return false;
11443
+ return _isParentRemoved(removes, n2);
11444
+ }
11445
+ function _isParentRemoved(removes, n2, _mirror2) {
11446
+ const node2 = index.parentNode(n2);
11447
+ if (!node2) return false;
11448
+ return removes.has(node2);
11454
11449
  }
11455
11450
  function isAncestorInSet(set, n2) {
11456
11451
  if (set.size === 0) return false;