@posthog/rrweb 0.0.10 → 0.0.11

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
@@ -5,7 +5,7 @@ var _a;
5
5
  var __defProp$1 = Object.defineProperty;
6
6
  var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7
7
  var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
8
- var NodeType$3 = /* @__PURE__ */ ((NodeType2) => {
8
+ var NodeType$1$1 = /* @__PURE__ */ ((NodeType2) => {
9
9
  NodeType2[NodeType2["Document"] = 0] = "Document";
10
10
  NodeType2[NodeType2["DocumentType"] = 1] = "DocumentType";
11
11
  NodeType2[NodeType2["Element"] = 2] = "Element";
@@ -13,7 +13,7 @@ var NodeType$3 = /* @__PURE__ */ ((NodeType2) => {
13
13
  NodeType2[NodeType2["CDATA"] = 4] = "CDATA";
14
14
  NodeType2[NodeType2["Comment"] = 5] = "Comment";
15
15
  return NodeType2;
16
- })(NodeType$3 || {});
16
+ })(NodeType$1$1 || {});
17
17
  const testableAccessors$1 = {
18
18
  Node: ["childNodes", "parentNode", "parentElement", "textContent"],
19
19
  ShadowRoot: ["host", "styleSheets"],
@@ -237,13 +237,9 @@ function stringifyStylesheet(s2) {
237
237
  if (!rules2) {
238
238
  return null;
239
239
  }
240
- let sheetHref = s2.href;
241
- if (!sheetHref && s2.ownerNode && s2.ownerNode.ownerDocument) {
242
- sheetHref = s2.ownerNode.ownerDocument.location.href;
243
- }
244
240
  const stringifiedRules = Array.from(
245
241
  rules2,
246
- (rule2) => stringifyRule(rule2, sheetHref)
242
+ (rule2) => stringifyRule(rule2, s2.href)
247
243
  ).join("");
248
244
  return fixBrowserCompatibilityIssuesInCSS(stringifiedRules);
249
245
  } catch (error) {
@@ -392,13 +388,13 @@ function is2DCanvasBlank(canvas) {
392
388
  }
393
389
  function isNodeMetaEqual(a2, b) {
394
390
  if (!a2 || !b || a2.type !== b.type) return false;
395
- if (a2.type === NodeType$3.Document)
391
+ if (a2.type === NodeType$1$1.Document)
396
392
  return a2.compatMode === b.compatMode;
397
- else if (a2.type === NodeType$3.DocumentType)
393
+ else if (a2.type === NodeType$1$1.DocumentType)
398
394
  return a2.name === b.name && a2.publicId === b.publicId && a2.systemId === b.systemId;
399
- else if (a2.type === NodeType$3.Comment || a2.type === NodeType$3.Text || a2.type === NodeType$3.CDATA)
395
+ else if (a2.type === NodeType$1$1.Comment || a2.type === NodeType$1$1.Text || a2.type === NodeType$1$1.CDATA)
400
396
  return a2.textContent === b.textContent;
401
- else if (a2.type === NodeType$3.Element)
397
+ else if (a2.type === NodeType$1$1.Element)
402
398
  return a2.tagName === b.tagName && JSON.stringify(a2.attributes) === JSON.stringify(b.attributes) && a2.isSVG === b.isSVG && a2.needBlock === b.needBlock;
403
399
  return false;
404
400
  }
@@ -468,90 +464,6 @@ function absolutifyURLs(cssText, href) {
468
464
  }
469
465
  );
470
466
  }
471
- const normalizationCache = /* @__PURE__ */ new Map();
472
- const splitCache = /* @__PURE__ */ new Map();
473
- function normalizeCssString(cssText) {
474
- if (!normalizationCache.has(cssText)) {
475
- const normalized = cssText.replace(/(\/\*[^*]*\*\/)|[\s;]/g, "");
476
- normalizationCache.set(cssText, normalized);
477
- }
478
- return normalizationCache.get(cssText);
479
- }
480
- function splitCssText(cssText, style) {
481
- const og = cssText;
482
- if (splitCache.has(cssText)) {
483
- return splitCache.get(cssText);
484
- }
485
- const childNodes2 = Array.from(style.childNodes);
486
- const splits = [];
487
- let iterLimit = 0;
488
- if (childNodes2.length > 1 && cssText && typeof cssText === "string") {
489
- let cssTextNorm = normalizeCssString(cssText);
490
- const normFactor = cssTextNorm.length / cssText.length;
491
- for (let i2 = 1; i2 < childNodes2.length; i2++) {
492
- if (childNodes2[i2].textContent && typeof childNodes2[i2].textContent === "string") {
493
- const textContentNorm = normalizeCssString(childNodes2[i2].textContent);
494
- let j = 3;
495
- for (; j < textContentNorm.length; j++) {
496
- if (
497
- // keep consuming css identifiers (to get a decent chunk more quickly)
498
- textContentNorm[j].match(/[a-zA-Z0-9]/) || // substring needs to be unique to this section
499
- textContentNorm.indexOf(textContentNorm.substring(0, j), 1) !== -1
500
- ) {
501
- continue;
502
- }
503
- break;
504
- }
505
- for (; j < textContentNorm.length; j++) {
506
- const bit = textContentNorm.substring(0, j);
507
- const bits = cssTextNorm.split(bit);
508
- let splitNorm = -1;
509
- if (bits.length === 2) {
510
- splitNorm = cssTextNorm.indexOf(bit);
511
- } else if (bits.length > 2 && bits[0] === "" && childNodes2[i2 - 1].textContent !== "") {
512
- splitNorm = cssTextNorm.indexOf(bit, 1);
513
- }
514
- if (splitNorm !== -1) {
515
- let k = Math.floor(splitNorm / normFactor);
516
- for (; k > 0 && k < cssText.length; ) {
517
- iterLimit += 1;
518
- if (iterLimit > 50 * childNodes2.length) {
519
- splits.push(cssText);
520
- return splits;
521
- }
522
- const normPart = normalizeCssString(cssText.substring(0, k));
523
- if (normPart.length === splitNorm) {
524
- splits.push(cssText.substring(0, k));
525
- cssText = cssText.substring(k);
526
- cssTextNorm = cssTextNorm.substring(splitNorm);
527
- break;
528
- } else if (normPart.length < splitNorm) {
529
- k += Math.max(
530
- 1,
531
- Math.floor((splitNorm - normPart.length) / normFactor)
532
- );
533
- } else {
534
- k -= Math.max(
535
- 1,
536
- Math.floor((normPart.length - splitNorm) * normFactor)
537
- );
538
- }
539
- }
540
- break;
541
- }
542
- }
543
- }
544
- }
545
- }
546
- splits.push(cssText);
547
- if (og) {
548
- splitCache.set(og, splits);
549
- }
550
- return splits;
551
- }
552
- function markCssSplits(cssText, style) {
553
- return splitCssText(cssText, style).join("/* rr_split */");
554
- }
555
467
  let _id = 1;
556
468
  const tagNameRegex = new RegExp("[^a-z0-9-_:]");
557
469
  const IGNORED_NODE = -2;
@@ -810,28 +722,27 @@ function serializeNode(n2, options) {
810
722
  inlineImages,
811
723
  recordCanvas,
812
724
  keepIframeSrcFn,
813
- newlyAddedElement = false,
814
- cssCaptured = false
725
+ newlyAddedElement = false
815
726
  } = options;
816
727
  const rootId = getRootId(doc, mirror2);
817
728
  switch (n2.nodeType) {
818
729
  case n2.DOCUMENT_NODE:
819
730
  if (n2.compatMode !== "CSS1Compat") {
820
731
  return {
821
- type: NodeType$3.Document,
732
+ type: NodeType$1$1.Document,
822
733
  childNodes: [],
823
734
  compatMode: n2.compatMode
824
735
  // probably "BackCompat"
825
736
  };
826
737
  } else {
827
738
  return {
828
- type: NodeType$3.Document,
739
+ type: NodeType$1$1.Document,
829
740
  childNodes: []
830
741
  };
831
742
  }
832
743
  case n2.DOCUMENT_TYPE_NODE:
833
744
  return {
834
- type: NodeType$3.DocumentType,
745
+ type: NodeType$1$1.DocumentType,
835
746
  name: n2.name,
836
747
  publicId: n2.publicId,
837
748
  systemId: n2.systemId,
@@ -857,18 +768,17 @@ function serializeNode(n2, options) {
857
768
  doc,
858
769
  needsMask,
859
770
  maskTextFn,
860
- rootId,
861
- cssCaptured
771
+ rootId
862
772
  });
863
773
  case n2.CDATA_SECTION_NODE:
864
774
  return {
865
- type: NodeType$3.CDATA,
775
+ type: NodeType$1$1.CDATA,
866
776
  textContent: "",
867
777
  rootId
868
778
  };
869
779
  case n2.COMMENT_NODE:
870
780
  return {
871
- type: NodeType$3.Comment,
781
+ type: NodeType$1$1.Comment,
872
782
  textContent: index$1.textContent(n2) || "",
873
783
  rootId
874
784
  };
@@ -882,26 +792,37 @@ function getRootId(doc, mirror2) {
882
792
  return docId === 1 ? void 0 : docId;
883
793
  }
884
794
  function serializeTextNode(n2, options) {
885
- const { needsMask, maskTextFn, rootId, cssCaptured } = options;
795
+ var _a2;
796
+ const { needsMask, maskTextFn, rootId } = options;
886
797
  const parent = index$1.parentNode(n2);
887
798
  const parentTagName = parent && parent.tagName;
888
- let textContent2 = "";
799
+ let text = index$1.textContent(n2);
889
800
  const isStyle = parentTagName === "STYLE" ? true : void 0;
890
801
  const isScript = parentTagName === "SCRIPT" ? true : void 0;
891
- if (isScript) {
892
- textContent2 = "SCRIPT_PLACEHOLDER";
893
- } else if (!cssCaptured) {
894
- textContent2 = index$1.textContent(n2);
895
- if (isStyle && textContent2) {
896
- textContent2 = absolutifyURLs(textContent2, getHref(options.doc));
802
+ if (isStyle && text) {
803
+ try {
804
+ if (n2.nextSibling || n2.previousSibling) {
805
+ } else if ((_a2 = parent.sheet) == null ? void 0 : _a2.cssRules) {
806
+ text = stringifyStylesheet(parent.sheet);
807
+ }
808
+ } catch (err) {
809
+ console.warn(
810
+ `Cannot get CSS styles from text's parentNode. Error: ${err}`,
811
+ n2
812
+ );
897
813
  }
814
+ text = absolutifyURLs(text, getHref(options.doc));
815
+ }
816
+ if (isScript) {
817
+ text = "SCRIPT_PLACEHOLDER";
898
818
  }
899
- if (!isStyle && !isScript && textContent2 && needsMask) {
900
- textContent2 = maskTextFn ? maskTextFn(textContent2, index$1.parentElement(n2)) : textContent2.replace(/[\S]/g, "*");
819
+ if (!isStyle && !isScript && text && needsMask) {
820
+ text = maskTextFn ? maskTextFn(text, index$1.parentElement(n2)) : text.replace(/[\S]/g, "*");
901
821
  }
902
822
  return {
903
- type: NodeType$3.Text,
904
- textContent: textContent2 || "",
823
+ type: NodeType$1$1.Text,
824
+ textContent: text || "",
825
+ isStyle,
905
826
  rootId
906
827
  };
907
828
  }
@@ -962,14 +883,12 @@ function serializeElementNode(n2, options) {
962
883
  }
963
884
  }
964
885
  }
965
- if (tagName === "style" && n2.sheet) {
966
- let cssText = stringifyStylesheet(
886
+ if (tagName === "style" && n2.sheet && // TODO: Currently we only try to get dynamic stylesheet when it is an empty style element
887
+ !(n2.innerText || index$1.textContent(n2) || "").trim().length) {
888
+ const cssText = stringifyStylesheet(
967
889
  n2.sheet
968
890
  );
969
891
  if (cssText) {
970
- if (n2.childNodes.length > 1) {
971
- cssText = markCssSplits(cssText, n2);
972
- }
973
892
  attributes._cssText = cssText;
974
893
  }
975
894
  }
@@ -1104,7 +1023,7 @@ function serializeElementNode(n2, options) {
1104
1023
  } catch (e2) {
1105
1024
  }
1106
1025
  return {
1107
- type: NodeType$3.Element,
1026
+ type: NodeType$1$1.Element,
1108
1027
  tagName,
1109
1028
  attributes,
1110
1029
  childNodes: [],
@@ -1122,9 +1041,9 @@ function lowerIfExists(maybeAttr) {
1122
1041
  }
1123
1042
  }
1124
1043
  function slimDOMExcluded(sn, slimDOMOptions) {
1125
- if (slimDOMOptions.comment && sn.type === NodeType$3.Comment) {
1044
+ if (slimDOMOptions.comment && sn.type === NodeType$1$1.Comment) {
1126
1045
  return true;
1127
- } else if (sn.type === NodeType$3.Element) {
1046
+ } else if (sn.type === NodeType$1$1.Element) {
1128
1047
  if (slimDOMOptions.script && // script tag
1129
1048
  (sn.tagName === "script" || // (module)preload link
1130
1049
  sn.tagName === "link" && (sn.attributes.rel === "preload" && sn.attributes.as === "script" || sn.attributes.rel === "modulepreload") || // prefetch link
@@ -1176,8 +1095,7 @@ function serializeNodeWithId(n2, options) {
1176
1095
  onStylesheetLoad,
1177
1096
  stylesheetLoadTimeout = 5e3,
1178
1097
  keepIframeSrcFn = () => false,
1179
- newlyAddedElement = false,
1180
- cssCaptured = false
1098
+ newlyAddedElement = false
1181
1099
  } = options;
1182
1100
  let { needsMask } = options;
1183
1101
  let { preserveWhiteSpace = true } = options;
@@ -1204,8 +1122,7 @@ function serializeNodeWithId(n2, options) {
1204
1122
  inlineImages,
1205
1123
  recordCanvas,
1206
1124
  keepIframeSrcFn,
1207
- newlyAddedElement,
1208
- cssCaptured
1125
+ newlyAddedElement
1209
1126
  });
1210
1127
  if (!_serializedNode) {
1211
1128
  console.warn(n2, "not serialized");
@@ -1214,7 +1131,7 @@ function serializeNodeWithId(n2, options) {
1214
1131
  let id;
1215
1132
  if (mirror2.hasNode(n2)) {
1216
1133
  id = mirror2.getId(n2);
1217
- } else if (slimDOMExcluded(_serializedNode, slimDOMOptions) || !preserveWhiteSpace && _serializedNode.type === NodeType$3.Text && !_serializedNode.textContent.replace(/^\s+|\s+$/gm, "").length) {
1134
+ } else if (slimDOMExcluded(_serializedNode, slimDOMOptions) || !preserveWhiteSpace && _serializedNode.type === NodeType$1$1.Text && !_serializedNode.isStyle && !_serializedNode.textContent.replace(/^\s+|\s+$/gm, "").length) {
1218
1135
  id = IGNORED_NODE;
1219
1136
  } else {
1220
1137
  id = genId();
@@ -1228,15 +1145,15 @@ function serializeNodeWithId(n2, options) {
1228
1145
  onSerialize(n2);
1229
1146
  }
1230
1147
  let recordChild = !skipChild;
1231
- if (serializedNode.type === NodeType$3.Element) {
1148
+ if (serializedNode.type === NodeType$1$1.Element) {
1232
1149
  recordChild = recordChild && !serializedNode.needBlock;
1233
1150
  delete serializedNode.needBlock;
1234
1151
  const shadowRootEl = index$1.shadowRoot(n2);
1235
1152
  if (shadowRootEl && isNativeShadowDom(shadowRootEl))
1236
1153
  serializedNode.isShadowHost = true;
1237
1154
  }
1238
- if ((serializedNode.type === NodeType$3.Document || serializedNode.type === NodeType$3.Element) && recordChild) {
1239
- if (slimDOMOptions.headWhitespace && serializedNode.type === NodeType$3.Element && serializedNode.tagName === "head") {
1155
+ if ((serializedNode.type === NodeType$1$1.Document || serializedNode.type === NodeType$1$1.Element) && recordChild) {
1156
+ if (slimDOMOptions.headWhitespace && serializedNode.type === NodeType$1$1.Element && serializedNode.tagName === "head") {
1240
1157
  preserveWhiteSpace = false;
1241
1158
  }
1242
1159
  const bypassOptions = {
@@ -1262,14 +1179,10 @@ function serializeNodeWithId(n2, options) {
1262
1179
  iframeLoadTimeout,
1263
1180
  onStylesheetLoad,
1264
1181
  stylesheetLoadTimeout,
1265
- keepIframeSrcFn,
1266
- cssCaptured: false
1182
+ keepIframeSrcFn
1267
1183
  };
1268
- if (serializedNode.type === NodeType$3.Element && serializedNode.tagName === "textarea" && serializedNode.attributes.value !== void 0) ;
1184
+ if (serializedNode.type === NodeType$1$1.Element && serializedNode.tagName === "textarea" && serializedNode.attributes.value !== void 0) ;
1269
1185
  else {
1270
- if (serializedNode.type === NodeType$3.Element && serializedNode.attributes._cssText !== void 0 && typeof serializedNode.attributes._cssText === "string") {
1271
- bypassOptions.cssCaptured = true;
1272
- }
1273
1186
  for (const childN of Array.from(index$1.childNodes(n2))) {
1274
1187
  const serializedChildNode = serializeNodeWithId(childN, bypassOptions);
1275
1188
  if (serializedChildNode) {
@@ -1292,7 +1205,7 @@ function serializeNodeWithId(n2, options) {
1292
1205
  if (parent && isShadowRoot(parent) && isNativeShadowDom(parent)) {
1293
1206
  serializedNode.isShadow = true;
1294
1207
  }
1295
- if (serializedNode.type === NodeType$3.Element && serializedNode.tagName === "iframe") {
1208
+ if (serializedNode.type === NodeType$1$1.Element && serializedNode.tagName === "iframe") {
1296
1209
  onceIframeLoaded(
1297
1210
  n2,
1298
1211
  () => {
@@ -1334,7 +1247,7 @@ function serializeNodeWithId(n2, options) {
1334
1247
  iframeLoadTimeout
1335
1248
  );
1336
1249
  }
1337
- if (serializedNode.type === NodeType$3.Element && serializedNode.tagName === "link" && typeof serializedNode.attributes.rel === "string" && (serializedNode.attributes.rel === "stylesheet" || serializedNode.attributes.rel === "preload" && typeof serializedNode.attributes.href === "string" && extractFileExtension(serializedNode.attributes.href) === "css")) {
1250
+ if (serializedNode.type === NodeType$1$1.Element && serializedNode.tagName === "link" && typeof serializedNode.attributes.rel === "string" && (serializedNode.attributes.rel === "stylesheet" || serializedNode.attributes.rel === "preload" && typeof serializedNode.attributes.href === "string" && extractFileExtension(serializedNode.attributes.href) === "css")) {
1338
1251
  onceStylesheetLoaded(
1339
1252
  n2,
1340
1253
  () => {
@@ -5478,49 +5391,19 @@ function createCache() {
5478
5391
  stylesWithHoverClass
5479
5392
  };
5480
5393
  }
5481
- function applyCssSplits(n2, cssText, hackCss, cache) {
5482
- const childTextNodes = [];
5483
- for (const scn of n2.childNodes) {
5484
- if (scn.type === NodeType$3.Text) {
5485
- childTextNodes.push(scn);
5486
- }
5487
- }
5488
- const cssTextSplits = cssText.split("/* rr_split */");
5489
- while (cssTextSplits.length > 1 && cssTextSplits.length > childTextNodes.length) {
5490
- cssTextSplits.splice(-2, 2, cssTextSplits.slice(-2).join(""));
5491
- }
5492
- for (let i2 = 0; i2 < childTextNodes.length; i2++) {
5493
- const childTextNode = childTextNodes[i2];
5494
- const cssTextSection = cssTextSplits[i2];
5495
- if (childTextNode && cssTextSection) {
5496
- childTextNode.textContent = hackCss ? adaptCssForReplay(cssTextSection, cache) : cssTextSection;
5497
- }
5498
- }
5499
- }
5500
- function buildStyleNode(n2, styleEl, cssText, options) {
5501
- const { doc, hackCss, cache } = options;
5502
- if (n2.childNodes.length) {
5503
- applyCssSplits(n2, cssText, hackCss, cache);
5504
- } else {
5505
- if (hackCss) {
5506
- cssText = adaptCssForReplay(cssText, cache);
5507
- }
5508
- styleEl.appendChild(doc.createTextNode(cssText));
5509
- }
5510
- }
5511
5394
  function buildNode(n2, options) {
5512
5395
  var _a2;
5513
5396
  const { doc, hackCss, cache } = options;
5514
5397
  switch (n2.type) {
5515
- case NodeType$3.Document:
5398
+ case NodeType$1$1.Document:
5516
5399
  return doc.implementation.createDocument(null, "", null);
5517
- case NodeType$3.DocumentType:
5400
+ case NodeType$1$1.DocumentType:
5518
5401
  return doc.implementation.createDocumentType(
5519
5402
  n2.name || "html",
5520
5403
  n2.publicId,
5521
5404
  n2.systemId
5522
5405
  );
5523
- case NodeType$3.Element: {
5406
+ case NodeType$1$1.Element: {
5524
5407
  const tagName = getTagName(n2);
5525
5408
  let node2;
5526
5409
  if (n2.isSVG) {
@@ -5556,11 +5439,12 @@ function buildNode(n2, options) {
5556
5439
  specialAttributes[name] = value;
5557
5440
  continue;
5558
5441
  }
5559
- if (typeof value !== "string") ;
5560
- else if (tagName === "style" && name === "_cssText") {
5561
- buildStyleNode(n2, node2, value, options);
5562
- continue;
5563
- } else if (tagName === "textarea" && name === "value") {
5442
+ const isTextarea = tagName === "textarea" && name === "value";
5443
+ const isRemoteOrDynamicCss = tagName === "style" && name === "_cssText";
5444
+ if (isRemoteOrDynamicCss && hackCss && typeof value === "string") {
5445
+ value = adaptCssForReplay(value, cache);
5446
+ }
5447
+ if ((isTextarea || isRemoteOrDynamicCss) && typeof value === "string") {
5564
5448
  node2.appendChild(doc.createTextNode(value));
5565
5449
  n2.childNodes = [];
5566
5450
  continue;
@@ -5654,14 +5538,13 @@ function buildNode(n2, options) {
5654
5538
  }
5655
5539
  return node2;
5656
5540
  }
5657
- case NodeType$3.Text:
5658
- if (n2.isStyle && hackCss) {
5659
- return doc.createTextNode(adaptCssForReplay(n2.textContent, cache));
5660
- }
5661
- return doc.createTextNode(n2.textContent);
5662
- case NodeType$3.CDATA:
5541
+ case NodeType$1$1.Text:
5542
+ return doc.createTextNode(
5543
+ n2.isStyle && hackCss ? adaptCssForReplay(n2.textContent, cache) : n2.textContent
5544
+ );
5545
+ case NodeType$1$1.CDATA:
5663
5546
  return doc.createCDATASection(n2.textContent);
5664
- case NodeType$3.Comment:
5547
+ case NodeType$1$1.Comment:
5665
5548
  return doc.createComment(n2.textContent);
5666
5549
  default:
5667
5550
  return null;
@@ -5688,11 +5571,11 @@ function buildNodeWithSN(n2, options) {
5688
5571
  if (n2.rootId && mirror2.getNode(n2.rootId) !== doc) {
5689
5572
  mirror2.replace(n2.rootId, doc);
5690
5573
  }
5691
- if (n2.type === NodeType$3.Document) {
5574
+ if (n2.type === NodeType$1$1.Document) {
5692
5575
  doc.close();
5693
5576
  doc.open();
5694
- if (n2.compatMode === "BackCompat" && n2.childNodes && n2.childNodes[0].type !== NodeType$3.DocumentType) {
5695
- if (n2.childNodes[0].type === NodeType$3.Element && "xmlns" in n2.childNodes[0].attributes && n2.childNodes[0].attributes.xmlns === "http://www.w3.org/1999/xhtml") {
5577
+ if (n2.compatMode === "BackCompat" && n2.childNodes && n2.childNodes[0].type !== NodeType$1$1.DocumentType) {
5578
+ if (n2.childNodes[0].type === NodeType$1$1.Element && "xmlns" in n2.childNodes[0].attributes && n2.childNodes[0].attributes.xmlns === "http://www.w3.org/1999/xhtml") {
5696
5579
  doc.write(
5697
5580
  '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">'
5698
5581
  );
@@ -5705,7 +5588,7 @@ function buildNodeWithSN(n2, options) {
5705
5588
  node2 = doc;
5706
5589
  }
5707
5590
  mirror2.add(node2, n2);
5708
- if ((n2.type === NodeType$3.Document || n2.type === NodeType$3.Element) && !skipChild) {
5591
+ if ((n2.type === NodeType$1$1.Document || n2.type === NodeType$1$1.Element) && !skipChild) {
5709
5592
  for (const childN of n2.childNodes) {
5710
5593
  const childNode = buildNodeWithSN(childN, {
5711
5594
  doc,
@@ -5721,7 +5604,7 @@ function buildNodeWithSN(n2, options) {
5721
5604
  }
5722
5605
  if (childN.isShadow && isElement(node2) && node2.shadowRoot) {
5723
5606
  node2.shadowRoot.appendChild(childNode);
5724
- } else if (n2.type === NodeType$3.Document && childN.type == NodeType$3.Element) {
5607
+ } else if (n2.type === NodeType$1$1.Document && childN.type == NodeType$1$1.Element) {
5725
5608
  const htmlElement = childNode;
5726
5609
  let body = null;
5727
5610
  htmlElement.childNodes.forEach((child) => {
@@ -5756,7 +5639,7 @@ function visit(mirror2, onVisit) {
5756
5639
  }
5757
5640
  function handleScroll(node2, mirror2) {
5758
5641
  const n2 = mirror2.getMeta(node2);
5759
- if ((n2 == null ? void 0 : n2.type) !== NodeType$3.Element) {
5642
+ if ((n2 == null ? void 0 : n2.type) !== NodeType$1$1.Element) {
5760
5643
  return;
5761
5644
  }
5762
5645
  const el = node2;
@@ -11845,18 +11728,9 @@ class MutationBuffer {
11845
11728
  };
11846
11729
  const pushAdd = (n2) => {
11847
11730
  const parent = index.parentNode(n2);
11848
- if (!parent || !inDom(n2)) {
11731
+ if (!parent || !inDom(n2) || parent.tagName === "TEXTAREA") {
11849
11732
  return;
11850
11733
  }
11851
- let cssCaptured = false;
11852
- if (n2.nodeType === Node.TEXT_NODE) {
11853
- const parentTag = parent.tagName;
11854
- if (parentTag === "TEXTAREA") {
11855
- return;
11856
- } else if (parentTag === "STYLE" && this.addedSet.has(parent)) {
11857
- cssCaptured = true;
11858
- }
11859
- }
11860
11734
  const parentId = isShadowRoot(parent) ? this.mirror.getId(getShadowHost(n2)) : this.mirror.getId(parent);
11861
11735
  const nextId = getNextId(n2);
11862
11736
  if (parentId === -1 || nextId === -1) {
@@ -11898,8 +11772,7 @@ class MutationBuffer {
11898
11772
  },
11899
11773
  onStylesheetLoad: (link, childSn) => {
11900
11774
  this.stylesheetManager.attachLinkElement(link, childSn);
11901
- },
11902
- cssCaptured
11775
+ }
11903
11776
  });
11904
11777
  if (sn) {
11905
11778
  adds.push({
@@ -16686,9 +16559,6 @@ class Replayer {
16686
16559
  "html.rrweb-paused *, html.rrweb-paused *:before, html.rrweb-paused *:after { animation-play-state: paused !important; }"
16687
16560
  );
16688
16561
  }
16689
- if (!injectStylesRules.length) {
16690
- return;
16691
- }
16692
16562
  if (this.usingVirtualDom) {
16693
16563
  const styleEl = this.virtualDom.createElement("style");
16694
16564
  this.virtualDom.mirror.add(
@@ -17363,12 +17233,7 @@ class Replayer {
17363
17233
  }
17364
17234
  return this.warnNodeNotFound(d, mutation.id);
17365
17235
  }
17366
- const parentEl = target.parentElement;
17367
- if (mutation.value && parentEl && parentEl.tagName === "STYLE") {
17368
- target.textContent = adaptCssForReplay(mutation.value, this.cache);
17369
- } else {
17370
- target.textContent = mutation.value;
17371
- }
17236
+ target.textContent = mutation.value;
17372
17237
  if (this.usingVirtualDom) {
17373
17238
  const parent = target.parentNode;
17374
17239
  if (((_a2 = parent == null ? void 0 : parent.rules) == null ? void 0 : _a2.length) > 0) parent.rules = [];