@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.
@@ -51,7 +51,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
51
51
  var __defProp$1 = Object.defineProperty;
52
52
  var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
53
53
  var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
54
- var NodeType$3 = /* @__PURE__ */ ((NodeType2) => {
54
+ var NodeType$1$1 = /* @__PURE__ */ ((NodeType2) => {
55
55
  NodeType2[NodeType2["Document"] = 0] = "Document";
56
56
  NodeType2[NodeType2["DocumentType"] = 1] = "DocumentType";
57
57
  NodeType2[NodeType2["Element"] = 2] = "Element";
@@ -59,7 +59,7 @@ var NodeType$3 = /* @__PURE__ */ ((NodeType2) => {
59
59
  NodeType2[NodeType2["CDATA"] = 4] = "CDATA";
60
60
  NodeType2[NodeType2["Comment"] = 5] = "Comment";
61
61
  return NodeType2;
62
- })(NodeType$3 || {});
62
+ })(NodeType$1$1 || {});
63
63
  const testableAccessors$1 = {
64
64
  Node: ["childNodes", "parentNode", "parentElement", "textContent"],
65
65
  ShadowRoot: ["host", "styleSheets"],
@@ -283,13 +283,9 @@ function stringifyStylesheet(s2) {
283
283
  if (!rules2) {
284
284
  return null;
285
285
  }
286
- let sheetHref = s2.href;
287
- if (!sheetHref && s2.ownerNode && s2.ownerNode.ownerDocument) {
288
- sheetHref = s2.ownerNode.ownerDocument.location.href;
289
- }
290
286
  const stringifiedRules = Array.from(
291
287
  rules2,
292
- (rule2) => stringifyRule(rule2, sheetHref)
288
+ (rule2) => stringifyRule(rule2, s2.href)
293
289
  ).join("");
294
290
  return fixBrowserCompatibilityIssuesInCSS(stringifiedRules);
295
291
  } catch (error) {
@@ -438,13 +434,13 @@ function is2DCanvasBlank(canvas) {
438
434
  }
439
435
  function isNodeMetaEqual(a2, b) {
440
436
  if (!a2 || !b || a2.type !== b.type) return false;
441
- if (a2.type === NodeType$3.Document)
437
+ if (a2.type === NodeType$1$1.Document)
442
438
  return a2.compatMode === b.compatMode;
443
- else if (a2.type === NodeType$3.DocumentType)
439
+ else if (a2.type === NodeType$1$1.DocumentType)
444
440
  return a2.name === b.name && a2.publicId === b.publicId && a2.systemId === b.systemId;
445
- else if (a2.type === NodeType$3.Comment || a2.type === NodeType$3.Text || a2.type === NodeType$3.CDATA)
441
+ else if (a2.type === NodeType$1$1.Comment || a2.type === NodeType$1$1.Text || a2.type === NodeType$1$1.CDATA)
446
442
  return a2.textContent === b.textContent;
447
- else if (a2.type === NodeType$3.Element)
443
+ else if (a2.type === NodeType$1$1.Element)
448
444
  return a2.tagName === b.tagName && JSON.stringify(a2.attributes) === JSON.stringify(b.attributes) && a2.isSVG === b.isSVG && a2.needBlock === b.needBlock;
449
445
  return false;
450
446
  }
@@ -515,90 +511,6 @@ function absolutifyURLs(cssText, href) {
515
511
  }
516
512
  );
517
513
  }
518
- const normalizationCache = /* @__PURE__ */ new Map();
519
- const splitCache = /* @__PURE__ */ new Map();
520
- function normalizeCssString(cssText) {
521
- if (!normalizationCache.has(cssText)) {
522
- const normalized = cssText.replace(/(\/\*[^*]*\*\/)|[\s;]/g, "");
523
- normalizationCache.set(cssText, normalized);
524
- }
525
- return normalizationCache.get(cssText);
526
- }
527
- function splitCssText(cssText, style) {
528
- const og = cssText;
529
- if (splitCache.has(cssText)) {
530
- return splitCache.get(cssText);
531
- }
532
- const childNodes2 = Array.from(style.childNodes);
533
- const splits = [];
534
- let iterLimit = 0;
535
- if (childNodes2.length > 1 && cssText && typeof cssText === "string") {
536
- let cssTextNorm = normalizeCssString(cssText);
537
- const normFactor = cssTextNorm.length / cssText.length;
538
- for (let i2 = 1; i2 < childNodes2.length; i2++) {
539
- if (childNodes2[i2].textContent && typeof childNodes2[i2].textContent === "string") {
540
- const textContentNorm = normalizeCssString(childNodes2[i2].textContent);
541
- let j = 3;
542
- for (; j < textContentNorm.length; j++) {
543
- if (
544
- // keep consuming css identifiers (to get a decent chunk more quickly)
545
- textContentNorm[j].match(/[a-zA-Z0-9]/) || // substring needs to be unique to this section
546
- textContentNorm.indexOf(textContentNorm.substring(0, j), 1) !== -1
547
- ) {
548
- continue;
549
- }
550
- break;
551
- }
552
- for (; j < textContentNorm.length; j++) {
553
- const bit = textContentNorm.substring(0, j);
554
- const bits = cssTextNorm.split(bit);
555
- let splitNorm = -1;
556
- if (bits.length === 2) {
557
- splitNorm = cssTextNorm.indexOf(bit);
558
- } else if (bits.length > 2 && bits[0] === "" && childNodes2[i2 - 1].textContent !== "") {
559
- splitNorm = cssTextNorm.indexOf(bit, 1);
560
- }
561
- if (splitNorm !== -1) {
562
- let k = Math.floor(splitNorm / normFactor);
563
- for (; k > 0 && k < cssText.length; ) {
564
- iterLimit += 1;
565
- if (iterLimit > 50 * childNodes2.length) {
566
- splits.push(cssText);
567
- return splits;
568
- }
569
- const normPart = normalizeCssString(cssText.substring(0, k));
570
- if (normPart.length === splitNorm) {
571
- splits.push(cssText.substring(0, k));
572
- cssText = cssText.substring(k);
573
- cssTextNorm = cssTextNorm.substring(splitNorm);
574
- break;
575
- } else if (normPart.length < splitNorm) {
576
- k += Math.max(
577
- 1,
578
- Math.floor((splitNorm - normPart.length) / normFactor)
579
- );
580
- } else {
581
- k -= Math.max(
582
- 1,
583
- Math.floor((normPart.length - splitNorm) * normFactor)
584
- );
585
- }
586
- }
587
- break;
588
- }
589
- }
590
- }
591
- }
592
- }
593
- splits.push(cssText);
594
- if (og) {
595
- splitCache.set(og, splits);
596
- }
597
- return splits;
598
- }
599
- function markCssSplits(cssText, style) {
600
- return splitCssText(cssText, style).join("/* rr_split */");
601
- }
602
514
  let _id = 1;
603
515
  const tagNameRegex = new RegExp("[^a-z0-9-_:]");
604
516
  const IGNORED_NODE = -2;
@@ -857,28 +769,27 @@ function serializeNode(n2, options) {
857
769
  inlineImages,
858
770
  recordCanvas,
859
771
  keepIframeSrcFn,
860
- newlyAddedElement = false,
861
- cssCaptured = false
772
+ newlyAddedElement = false
862
773
  } = options;
863
774
  const rootId = getRootId(doc, mirror2);
864
775
  switch (n2.nodeType) {
865
776
  case n2.DOCUMENT_NODE:
866
777
  if (n2.compatMode !== "CSS1Compat") {
867
778
  return {
868
- type: NodeType$3.Document,
779
+ type: NodeType$1$1.Document,
869
780
  childNodes: [],
870
781
  compatMode: n2.compatMode
871
782
  // probably "BackCompat"
872
783
  };
873
784
  } else {
874
785
  return {
875
- type: NodeType$3.Document,
786
+ type: NodeType$1$1.Document,
876
787
  childNodes: []
877
788
  };
878
789
  }
879
790
  case n2.DOCUMENT_TYPE_NODE:
880
791
  return {
881
- type: NodeType$3.DocumentType,
792
+ type: NodeType$1$1.DocumentType,
882
793
  name: n2.name,
883
794
  publicId: n2.publicId,
884
795
  systemId: n2.systemId,
@@ -904,18 +815,17 @@ function serializeNode(n2, options) {
904
815
  doc,
905
816
  needsMask,
906
817
  maskTextFn,
907
- rootId,
908
- cssCaptured
818
+ rootId
909
819
  });
910
820
  case n2.CDATA_SECTION_NODE:
911
821
  return {
912
- type: NodeType$3.CDATA,
822
+ type: NodeType$1$1.CDATA,
913
823
  textContent: "",
914
824
  rootId
915
825
  };
916
826
  case n2.COMMENT_NODE:
917
827
  return {
918
- type: NodeType$3.Comment,
828
+ type: NodeType$1$1.Comment,
919
829
  textContent: index$1.textContent(n2) || "",
920
830
  rootId
921
831
  };
@@ -929,26 +839,37 @@ function getRootId(doc, mirror2) {
929
839
  return docId === 1 ? void 0 : docId;
930
840
  }
931
841
  function serializeTextNode(n2, options) {
932
- const { needsMask, maskTextFn, rootId, cssCaptured } = options;
842
+ var _a2;
843
+ const { needsMask, maskTextFn, rootId } = options;
933
844
  const parent = index$1.parentNode(n2);
934
845
  const parentTagName = parent && parent.tagName;
935
- let textContent2 = "";
846
+ let text = index$1.textContent(n2);
936
847
  const isStyle = parentTagName === "STYLE" ? true : void 0;
937
848
  const isScript = parentTagName === "SCRIPT" ? true : void 0;
938
- if (isScript) {
939
- textContent2 = "SCRIPT_PLACEHOLDER";
940
- } else if (!cssCaptured) {
941
- textContent2 = index$1.textContent(n2);
942
- if (isStyle && textContent2) {
943
- textContent2 = absolutifyURLs(textContent2, getHref(options.doc));
849
+ if (isStyle && text) {
850
+ try {
851
+ if (n2.nextSibling || n2.previousSibling) {
852
+ } else if ((_a2 = parent.sheet) == null ? void 0 : _a2.cssRules) {
853
+ text = stringifyStylesheet(parent.sheet);
854
+ }
855
+ } catch (err) {
856
+ console.warn(
857
+ `Cannot get CSS styles from text's parentNode. Error: ${err}`,
858
+ n2
859
+ );
944
860
  }
861
+ text = absolutifyURLs(text, getHref(options.doc));
862
+ }
863
+ if (isScript) {
864
+ text = "SCRIPT_PLACEHOLDER";
945
865
  }
946
- if (!isStyle && !isScript && textContent2 && needsMask) {
947
- textContent2 = maskTextFn ? maskTextFn(textContent2, index$1.parentElement(n2)) : textContent2.replace(/[\S]/g, "*");
866
+ if (!isStyle && !isScript && text && needsMask) {
867
+ text = maskTextFn ? maskTextFn(text, index$1.parentElement(n2)) : text.replace(/[\S]/g, "*");
948
868
  }
949
869
  return {
950
- type: NodeType$3.Text,
951
- textContent: textContent2 || "",
870
+ type: NodeType$1$1.Text,
871
+ textContent: text || "",
872
+ isStyle,
952
873
  rootId
953
874
  };
954
875
  }
@@ -1009,14 +930,12 @@ function serializeElementNode(n2, options) {
1009
930
  }
1010
931
  }
1011
932
  }
1012
- if (tagName === "style" && n2.sheet) {
1013
- let cssText = stringifyStylesheet(
933
+ if (tagName === "style" && n2.sheet && // TODO: Currently we only try to get dynamic stylesheet when it is an empty style element
934
+ !(n2.innerText || index$1.textContent(n2) || "").trim().length) {
935
+ const cssText = stringifyStylesheet(
1014
936
  n2.sheet
1015
937
  );
1016
938
  if (cssText) {
1017
- if (n2.childNodes.length > 1) {
1018
- cssText = markCssSplits(cssText, n2);
1019
- }
1020
939
  attributes._cssText = cssText;
1021
940
  }
1022
941
  }
@@ -1151,7 +1070,7 @@ function serializeElementNode(n2, options) {
1151
1070
  } catch (e2) {
1152
1071
  }
1153
1072
  return {
1154
- type: NodeType$3.Element,
1073
+ type: NodeType$1$1.Element,
1155
1074
  tagName,
1156
1075
  attributes,
1157
1076
  childNodes: [],
@@ -1169,9 +1088,9 @@ function lowerIfExists(maybeAttr) {
1169
1088
  }
1170
1089
  }
1171
1090
  function slimDOMExcluded(sn, slimDOMOptions) {
1172
- if (slimDOMOptions.comment && sn.type === NodeType$3.Comment) {
1091
+ if (slimDOMOptions.comment && sn.type === NodeType$1$1.Comment) {
1173
1092
  return true;
1174
- } else if (sn.type === NodeType$3.Element) {
1093
+ } else if (sn.type === NodeType$1$1.Element) {
1175
1094
  if (slimDOMOptions.script && // script tag
1176
1095
  (sn.tagName === "script" || // (module)preload link
1177
1096
  sn.tagName === "link" && (sn.attributes.rel === "preload" && sn.attributes.as === "script" || sn.attributes.rel === "modulepreload") || // prefetch link
@@ -1223,8 +1142,7 @@ function serializeNodeWithId(n2, options) {
1223
1142
  onStylesheetLoad,
1224
1143
  stylesheetLoadTimeout = 5e3,
1225
1144
  keepIframeSrcFn = () => false,
1226
- newlyAddedElement = false,
1227
- cssCaptured = false
1145
+ newlyAddedElement = false
1228
1146
  } = options;
1229
1147
  let { needsMask } = options;
1230
1148
  let { preserveWhiteSpace = true } = options;
@@ -1251,8 +1169,7 @@ function serializeNodeWithId(n2, options) {
1251
1169
  inlineImages,
1252
1170
  recordCanvas,
1253
1171
  keepIframeSrcFn,
1254
- newlyAddedElement,
1255
- cssCaptured
1172
+ newlyAddedElement
1256
1173
  });
1257
1174
  if (!_serializedNode) {
1258
1175
  console.warn(n2, "not serialized");
@@ -1261,7 +1178,7 @@ function serializeNodeWithId(n2, options) {
1261
1178
  let id;
1262
1179
  if (mirror2.hasNode(n2)) {
1263
1180
  id = mirror2.getId(n2);
1264
- } else if (slimDOMExcluded(_serializedNode, slimDOMOptions) || !preserveWhiteSpace && _serializedNode.type === NodeType$3.Text && !_serializedNode.textContent.replace(/^\s+|\s+$/gm, "").length) {
1181
+ } else if (slimDOMExcluded(_serializedNode, slimDOMOptions) || !preserveWhiteSpace && _serializedNode.type === NodeType$1$1.Text && !_serializedNode.isStyle && !_serializedNode.textContent.replace(/^\s+|\s+$/gm, "").length) {
1265
1182
  id = IGNORED_NODE;
1266
1183
  } else {
1267
1184
  id = genId();
@@ -1275,15 +1192,15 @@ function serializeNodeWithId(n2, options) {
1275
1192
  onSerialize(n2);
1276
1193
  }
1277
1194
  let recordChild = !skipChild;
1278
- if (serializedNode.type === NodeType$3.Element) {
1195
+ if (serializedNode.type === NodeType$1$1.Element) {
1279
1196
  recordChild = recordChild && !serializedNode.needBlock;
1280
1197
  delete serializedNode.needBlock;
1281
1198
  const shadowRootEl = index$1.shadowRoot(n2);
1282
1199
  if (shadowRootEl && isNativeShadowDom(shadowRootEl))
1283
1200
  serializedNode.isShadowHost = true;
1284
1201
  }
1285
- if ((serializedNode.type === NodeType$3.Document || serializedNode.type === NodeType$3.Element) && recordChild) {
1286
- if (slimDOMOptions.headWhitespace && serializedNode.type === NodeType$3.Element && serializedNode.tagName === "head") {
1202
+ if ((serializedNode.type === NodeType$1$1.Document || serializedNode.type === NodeType$1$1.Element) && recordChild) {
1203
+ if (slimDOMOptions.headWhitespace && serializedNode.type === NodeType$1$1.Element && serializedNode.tagName === "head") {
1287
1204
  preserveWhiteSpace = false;
1288
1205
  }
1289
1206
  const bypassOptions = {
@@ -1309,14 +1226,10 @@ function serializeNodeWithId(n2, options) {
1309
1226
  iframeLoadTimeout,
1310
1227
  onStylesheetLoad,
1311
1228
  stylesheetLoadTimeout,
1312
- keepIframeSrcFn,
1313
- cssCaptured: false
1229
+ keepIframeSrcFn
1314
1230
  };
1315
- if (serializedNode.type === NodeType$3.Element && serializedNode.tagName === "textarea" && serializedNode.attributes.value !== void 0) ;
1231
+ if (serializedNode.type === NodeType$1$1.Element && serializedNode.tagName === "textarea" && serializedNode.attributes.value !== void 0) ;
1316
1232
  else {
1317
- if (serializedNode.type === NodeType$3.Element && serializedNode.attributes._cssText !== void 0 && typeof serializedNode.attributes._cssText === "string") {
1318
- bypassOptions.cssCaptured = true;
1319
- }
1320
1233
  for (const childN of Array.from(index$1.childNodes(n2))) {
1321
1234
  const serializedChildNode = serializeNodeWithId(childN, bypassOptions);
1322
1235
  if (serializedChildNode) {
@@ -1339,7 +1252,7 @@ function serializeNodeWithId(n2, options) {
1339
1252
  if (parent && isShadowRoot(parent) && isNativeShadowDom(parent)) {
1340
1253
  serializedNode.isShadow = true;
1341
1254
  }
1342
- if (serializedNode.type === NodeType$3.Element && serializedNode.tagName === "iframe") {
1255
+ if (serializedNode.type === NodeType$1$1.Element && serializedNode.tagName === "iframe") {
1343
1256
  onceIframeLoaded(
1344
1257
  n2,
1345
1258
  () => {
@@ -1381,7 +1294,7 @@ function serializeNodeWithId(n2, options) {
1381
1294
  iframeLoadTimeout
1382
1295
  );
1383
1296
  }
1384
- 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")) {
1297
+ 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")) {
1385
1298
  onceStylesheetLoaded(
1386
1299
  n2,
1387
1300
  () => {
@@ -5524,49 +5437,19 @@ function createCache() {
5524
5437
  stylesWithHoverClass
5525
5438
  };
5526
5439
  }
5527
- function applyCssSplits(n2, cssText, hackCss, cache) {
5528
- const childTextNodes = [];
5529
- for (const scn of n2.childNodes) {
5530
- if (scn.type === NodeType$3.Text) {
5531
- childTextNodes.push(scn);
5532
- }
5533
- }
5534
- const cssTextSplits = cssText.split("/* rr_split */");
5535
- while (cssTextSplits.length > 1 && cssTextSplits.length > childTextNodes.length) {
5536
- cssTextSplits.splice(-2, 2, cssTextSplits.slice(-2).join(""));
5537
- }
5538
- for (let i2 = 0; i2 < childTextNodes.length; i2++) {
5539
- const childTextNode = childTextNodes[i2];
5540
- const cssTextSection = cssTextSplits[i2];
5541
- if (childTextNode && cssTextSection) {
5542
- childTextNode.textContent = hackCss ? adaptCssForReplay(cssTextSection, cache) : cssTextSection;
5543
- }
5544
- }
5545
- }
5546
- function buildStyleNode(n2, styleEl, cssText, options) {
5547
- const { doc, hackCss, cache } = options;
5548
- if (n2.childNodes.length) {
5549
- applyCssSplits(n2, cssText, hackCss, cache);
5550
- } else {
5551
- if (hackCss) {
5552
- cssText = adaptCssForReplay(cssText, cache);
5553
- }
5554
- styleEl.appendChild(doc.createTextNode(cssText));
5555
- }
5556
- }
5557
5440
  function buildNode(n2, options) {
5558
5441
  var _a2;
5559
5442
  const { doc, hackCss, cache } = options;
5560
5443
  switch (n2.type) {
5561
- case NodeType$3.Document:
5444
+ case NodeType$1$1.Document:
5562
5445
  return doc.implementation.createDocument(null, "", null);
5563
- case NodeType$3.DocumentType:
5446
+ case NodeType$1$1.DocumentType:
5564
5447
  return doc.implementation.createDocumentType(
5565
5448
  n2.name || "html",
5566
5449
  n2.publicId,
5567
5450
  n2.systemId
5568
5451
  );
5569
- case NodeType$3.Element: {
5452
+ case NodeType$1$1.Element: {
5570
5453
  const tagName = getTagName(n2);
5571
5454
  let node2;
5572
5455
  if (n2.isSVG) {
@@ -5602,11 +5485,12 @@ function buildNode(n2, options) {
5602
5485
  specialAttributes[name] = value;
5603
5486
  continue;
5604
5487
  }
5605
- if (typeof value !== "string") ;
5606
- else if (tagName === "style" && name === "_cssText") {
5607
- buildStyleNode(n2, node2, value, options);
5608
- continue;
5609
- } else if (tagName === "textarea" && name === "value") {
5488
+ const isTextarea = tagName === "textarea" && name === "value";
5489
+ const isRemoteOrDynamicCss = tagName === "style" && name === "_cssText";
5490
+ if (isRemoteOrDynamicCss && hackCss && typeof value === "string") {
5491
+ value = adaptCssForReplay(value, cache);
5492
+ }
5493
+ if ((isTextarea || isRemoteOrDynamicCss) && typeof value === "string") {
5610
5494
  node2.appendChild(doc.createTextNode(value));
5611
5495
  n2.childNodes = [];
5612
5496
  continue;
@@ -5700,14 +5584,13 @@ function buildNode(n2, options) {
5700
5584
  }
5701
5585
  return node2;
5702
5586
  }
5703
- case NodeType$3.Text:
5704
- if (n2.isStyle && hackCss) {
5705
- return doc.createTextNode(adaptCssForReplay(n2.textContent, cache));
5706
- }
5707
- return doc.createTextNode(n2.textContent);
5708
- case NodeType$3.CDATA:
5587
+ case NodeType$1$1.Text:
5588
+ return doc.createTextNode(
5589
+ n2.isStyle && hackCss ? adaptCssForReplay(n2.textContent, cache) : n2.textContent
5590
+ );
5591
+ case NodeType$1$1.CDATA:
5709
5592
  return doc.createCDATASection(n2.textContent);
5710
- case NodeType$3.Comment:
5593
+ case NodeType$1$1.Comment:
5711
5594
  return doc.createComment(n2.textContent);
5712
5595
  default:
5713
5596
  return null;
@@ -5734,11 +5617,11 @@ function buildNodeWithSN(n2, options) {
5734
5617
  if (n2.rootId && mirror2.getNode(n2.rootId) !== doc) {
5735
5618
  mirror2.replace(n2.rootId, doc);
5736
5619
  }
5737
- if (n2.type === NodeType$3.Document) {
5620
+ if (n2.type === NodeType$1$1.Document) {
5738
5621
  doc.close();
5739
5622
  doc.open();
5740
- if (n2.compatMode === "BackCompat" && n2.childNodes && n2.childNodes[0].type !== NodeType$3.DocumentType) {
5741
- 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") {
5623
+ if (n2.compatMode === "BackCompat" && n2.childNodes && n2.childNodes[0].type !== NodeType$1$1.DocumentType) {
5624
+ 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") {
5742
5625
  doc.write(
5743
5626
  '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">'
5744
5627
  );
@@ -5751,7 +5634,7 @@ function buildNodeWithSN(n2, options) {
5751
5634
  node2 = doc;
5752
5635
  }
5753
5636
  mirror2.add(node2, n2);
5754
- if ((n2.type === NodeType$3.Document || n2.type === NodeType$3.Element) && !skipChild) {
5637
+ if ((n2.type === NodeType$1$1.Document || n2.type === NodeType$1$1.Element) && !skipChild) {
5755
5638
  for (const childN of n2.childNodes) {
5756
5639
  const childNode = buildNodeWithSN(childN, {
5757
5640
  doc,
@@ -5767,7 +5650,7 @@ function buildNodeWithSN(n2, options) {
5767
5650
  }
5768
5651
  if (childN.isShadow && isElement(node2) && node2.shadowRoot) {
5769
5652
  node2.shadowRoot.appendChild(childNode);
5770
- } else if (n2.type === NodeType$3.Document && childN.type == NodeType$3.Element) {
5653
+ } else if (n2.type === NodeType$1$1.Document && childN.type == NodeType$1$1.Element) {
5771
5654
  const htmlElement = childNode;
5772
5655
  let body = null;
5773
5656
  htmlElement.childNodes.forEach((child) => {
@@ -5802,7 +5685,7 @@ function visit(mirror2, onVisit) {
5802
5685
  }
5803
5686
  function handleScroll(node2, mirror2) {
5804
5687
  const n2 = mirror2.getMeta(node2);
5805
- if ((n2 == null ? void 0 : n2.type) !== NodeType$3.Element) {
5688
+ if ((n2 == null ? void 0 : n2.type) !== NodeType$1$1.Element) {
5806
5689
  return;
5807
5690
  }
5808
5691
  const el = node2;
@@ -11874,18 +11757,9 @@ class MutationBuffer {
11874
11757
  };
11875
11758
  const pushAdd = (n2) => {
11876
11759
  const parent = index.parentNode(n2);
11877
- if (!parent || !inDom(n2)) {
11760
+ if (!parent || !inDom(n2) || parent.tagName === "TEXTAREA") {
11878
11761
  return;
11879
11762
  }
11880
- let cssCaptured = false;
11881
- if (n2.nodeType === Node.TEXT_NODE) {
11882
- const parentTag = parent.tagName;
11883
- if (parentTag === "TEXTAREA") {
11884
- return;
11885
- } else if (parentTag === "STYLE" && this.addedSet.has(parent)) {
11886
- cssCaptured = true;
11887
- }
11888
- }
11889
11763
  const parentId = isShadowRoot(parent) ? this.mirror.getId(getShadowHost(n2)) : this.mirror.getId(parent);
11890
11764
  const nextId = getNextId(n2);
11891
11765
  if (parentId === -1 || nextId === -1) {
@@ -11927,8 +11801,7 @@ class MutationBuffer {
11927
11801
  },
11928
11802
  onStylesheetLoad: (link, childSn) => {
11929
11803
  this.stylesheetManager.attachLinkElement(link, childSn);
11930
- },
11931
- cssCaptured
11804
+ }
11932
11805
  });
11933
11806
  if (sn) {
11934
11807
  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(
@@ -17361,12 +17231,7 @@ class Replayer {
17361
17231
  }
17362
17232
  return this.warnNodeNotFound(d, mutation.id);
17363
17233
  }
17364
- const parentEl = target.parentElement;
17365
- if (mutation.value && parentEl && parentEl.tagName === "STYLE") {
17366
- target.textContent = adaptCssForReplay(mutation.value, this.cache);
17367
- } else {
17368
- target.textContent = mutation.value;
17369
- }
17234
+ target.textContent = mutation.value;
17370
17235
  if (this.usingVirtualDom) {
17371
17236
  const parent = target.parentNode;
17372
17237
  if (((_a2 = parent == null ? void 0 : parent.rules) == null ? void 0 : _a2.length) > 0) parent.rules = [];