@appsurify-testmap/rrweb-snapshot 2.1.0-alpha.2 → 2.1.0-alpha.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.
@@ -886,28 +886,14 @@ function transformAttribute(doc, tagName, name, value) {
886
886
  }
887
887
  return value;
888
888
  }
889
- function isIgnoreAttribute(tagName, name, _value) {
889
+ function ignoreAttribute(tagName, name, _value) {
890
890
  return (tagName === "video" || tagName === "audio") && name === "autoplay";
891
891
  }
892
- function cleanAttributes(doc, element, ignoreAttribute) {
893
- const tagName = getValidTagName(element);
894
- const attributes = {};
895
- const len = element.attributes.length;
896
- for (let i = 0; i < len; i++) {
897
- const attr = element.attributes[i];
898
- const name = attr.name;
899
- const value = attr.value;
900
- const shouldIgnoreByName = typeof ignoreAttribute === "string" ? name === ignoreAttribute : ignoreAttribute.test(name);
901
- if (!shouldIgnoreByName && !isIgnoreAttribute(tagName, name)) {
902
- attributes[name] = transformAttribute(
903
- doc,
904
- tagName,
905
- toLowerCase(name),
906
- value
907
- );
908
- }
909
- }
910
- return attributes;
892
+ function isIncludeAttribute(name, include) {
893
+ return typeof include === "string" ? name.includes(include) : include.test(name);
894
+ }
895
+ function isExcludeAttribute(name, exclude) {
896
+ return typeof exclude === "string" ? name.includes(exclude) : exclude.test(name);
911
897
  }
912
898
  function _isBlockedElement(element, blockClass, blockSelector) {
913
899
  try {
@@ -1038,7 +1024,8 @@ function serializeNode(n, options) {
1038
1024
  mirror,
1039
1025
  blockClass,
1040
1026
  blockSelector,
1041
- ignoreAttribute,
1027
+ excludeAttribute,
1028
+ includeAttribute,
1042
1029
  needsMask,
1043
1030
  inlineStylesheet,
1044
1031
  maskInputOptions = {},
@@ -1084,7 +1071,8 @@ function serializeNode(n, options) {
1084
1071
  doc,
1085
1072
  blockClass,
1086
1073
  blockSelector,
1087
- ignoreAttribute,
1074
+ excludeAttribute,
1075
+ includeAttribute,
1088
1076
  inlineStylesheet,
1089
1077
  maskInputOptions,
1090
1078
  maskInputFn,
@@ -1162,7 +1150,8 @@ function serializeElementNode(n, options) {
1162
1150
  doc,
1163
1151
  blockClass,
1164
1152
  blockSelector,
1165
- ignoreAttribute,
1153
+ excludeAttribute,
1154
+ includeAttribute,
1166
1155
  inlineStylesheet,
1167
1156
  maskInputOptions = {},
1168
1157
  maskInputFn,
@@ -1176,7 +1165,22 @@ function serializeElementNode(n, options) {
1176
1165
  } = options;
1177
1166
  const needBlock = _isBlockedElement(n, blockClass, blockSelector);
1178
1167
  const tagName = getValidTagName(n);
1179
- let attributes = cleanAttributes(doc, n, ignoreAttribute);
1168
+ let attributes = {};
1169
+ const len = n.attributes.length;
1170
+ for (let i = 0; i < len; i++) {
1171
+ const attr = n.attributes[i];
1172
+ if (isExcludeAttribute(attr.name, excludeAttribute) && !isIncludeAttribute(attr.name, includeAttribute)) {
1173
+ continue;
1174
+ }
1175
+ if (!ignoreAttribute(tagName, attr.name, attr.value)) {
1176
+ attributes[attr.name] = transformAttribute(
1177
+ doc,
1178
+ tagName,
1179
+ toLowerCase(attr.name),
1180
+ attr.value
1181
+ );
1182
+ }
1183
+ }
1180
1184
  if (tagName === "link" && inlineStylesheet) {
1181
1185
  const stylesheet = Array.from(doc.styleSheets).find((s) => {
1182
1186
  return s.href === n.href;
@@ -1390,7 +1394,8 @@ function serializeNodeWithId(n, options) {
1390
1394
  blockSelector,
1391
1395
  maskTextClass,
1392
1396
  maskTextSelector,
1393
- ignoreAttribute,
1397
+ excludeAttribute,
1398
+ includeAttribute,
1394
1399
  skipChild = false,
1395
1400
  inlineStylesheet = true,
1396
1401
  maskInputOptions = {},
@@ -1425,7 +1430,8 @@ function serializeNodeWithId(n, options) {
1425
1430
  mirror,
1426
1431
  blockClass,
1427
1432
  blockSelector,
1428
- ignoreAttribute,
1433
+ excludeAttribute,
1434
+ includeAttribute,
1429
1435
  needsMask,
1430
1436
  inlineStylesheet,
1431
1437
  maskInputOptions,
@@ -1478,7 +1484,8 @@ function serializeNodeWithId(n, options) {
1478
1484
  needsMask,
1479
1485
  maskTextClass,
1480
1486
  maskTextSelector,
1481
- ignoreAttribute,
1487
+ excludeAttribute,
1488
+ includeAttribute,
1482
1489
  skipChild,
1483
1490
  inlineStylesheet,
1484
1491
  maskInputOptions,
@@ -1538,7 +1545,8 @@ function serializeNodeWithId(n, options) {
1538
1545
  needsMask,
1539
1546
  maskTextClass,
1540
1547
  maskTextSelector,
1541
- ignoreAttribute,
1548
+ excludeAttribute,
1549
+ includeAttribute,
1542
1550
  skipChild: false,
1543
1551
  inlineStylesheet,
1544
1552
  maskInputOptions,
@@ -1580,7 +1588,8 @@ function serializeNodeWithId(n, options) {
1580
1588
  needsMask,
1581
1589
  maskTextClass,
1582
1590
  maskTextSelector,
1583
- ignoreAttribute,
1591
+ excludeAttribute,
1592
+ includeAttribute,
1584
1593
  skipChild: false,
1585
1594
  inlineStylesheet,
1586
1595
  maskInputOptions,
@@ -1618,7 +1627,8 @@ function snapshot(n, options) {
1618
1627
  blockSelector = null,
1619
1628
  maskTextClass = "rr-mask",
1620
1629
  maskTextSelector = null,
1621
- ignoreAttribute = "rr-ignore",
1630
+ excludeAttribute = /^$a/,
1631
+ includeAttribute = /.+/i,
1622
1632
  inlineStylesheet = true,
1623
1633
  inlineImages = false,
1624
1634
  recordCanvas = false,
@@ -1678,7 +1688,8 @@ function snapshot(n, options) {
1678
1688
  blockSelector,
1679
1689
  maskTextClass,
1680
1690
  maskTextSelector,
1681
- ignoreAttribute,
1691
+ excludeAttribute,
1692
+ includeAttribute,
1682
1693
  skipChild: false,
1683
1694
  inlineStylesheet,
1684
1695
  maskInputOptions,
@@ -5726,6 +5737,7 @@ export {
5726
5737
  genId,
5727
5738
  getInputType,
5728
5739
  getXPath,
5740
+ ignoreAttribute,
5729
5741
  interactiveEvents,
5730
5742
  interactiveTags,
5731
5743
  is2DCanvasBlank,
@@ -5734,7 +5746,8 @@ export {
5734
5746
  isElement,
5735
5747
  isElementInteractive,
5736
5748
  isElementVisible,
5737
- isIgnoreAttribute,
5749
+ isExcludeAttribute,
5750
+ isIncludeAttribute,
5738
5751
  isNativeShadowDom,
5739
5752
  isNodeMetaEqual,
5740
5753
  isShadowRoot,