@posthog/rrweb 0.0.10 → 0.0.12

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