@posthog/rrweb 0.0.20 → 0.0.21

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
@@ -239,9 +239,13 @@ 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.baseURI;
245
+ }
242
246
  const stringifiedRules = Array.from(
243
247
  rules2,
244
- (rule2) => stringifyRule(rule2, s2.href)
248
+ (rule2) => stringifyRule(rule2, sheetHref)
245
249
  ).join("");
246
250
  return fixBrowserCompatibilityIssuesInCSS(stringifiedRules);
247
251
  } catch (error) {
@@ -249,6 +253,7 @@ function stringifyStylesheet(s2) {
249
253
  }
250
254
  }
251
255
  function stringifyRule(rule2, sheetHref) {
256
+ var _a2;
252
257
  if (isCSSImportRule(rule2)) {
253
258
  let importStringified;
254
259
  try {
@@ -259,8 +264,11 @@ function stringifyRule(rule2, sheetHref) {
259
264
  } catch (error) {
260
265
  importStringified = rule2.cssText;
261
266
  }
262
- if (rule2.styleSheet.href) {
263
- return absolutifyURLs(importStringified, rule2.styleSheet.href);
267
+ try {
268
+ if (importStringified && ((_a2 = rule2.styleSheet) == null ? void 0 : _a2.href)) {
269
+ return absolutifyURLs(importStringified, rule2.styleSheet.href);
270
+ }
271
+ } catch {
264
272
  }
265
273
  return importStringified;
266
274
  } else {
@@ -5393,6 +5401,16 @@ function createCache() {
5393
5401
  stylesWithHoverClass
5394
5402
  };
5395
5403
  }
5404
+ function safeDocNode(n2, options) {
5405
+ let stringContent = n2.textContent;
5406
+ if (n2.isStyle && options.hackCss) {
5407
+ try {
5408
+ stringContent = adaptCssForReplay(n2.textContent, options.cache);
5409
+ } catch {
5410
+ }
5411
+ }
5412
+ return options.doc.createTextNode(stringContent);
5413
+ }
5396
5414
  function buildNode(n2, options) {
5397
5415
  var _a2;
5398
5416
  const { doc, hackCss, cache } = options;
@@ -5541,9 +5559,11 @@ function buildNode(n2, options) {
5541
5559
  return node2;
5542
5560
  }
5543
5561
  case NodeType$1$1.Text:
5544
- return doc.createTextNode(
5545
- n2.isStyle && hackCss ? adaptCssForReplay(n2.textContent, cache) : n2.textContent
5546
- );
5562
+ return safeDocNode(n2, {
5563
+ cache,
5564
+ doc,
5565
+ hackCss
5566
+ });
5547
5567
  case NodeType$1$1.CDATA:
5548
5568
  if (n2.textContent.trim() === "") {
5549
5569
  return null;