@posthog/rrweb-snapshot 0.0.19 → 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.
@@ -279,9 +279,13 @@ function stringifyStylesheet(s) {
279
279
  if (!rules) {
280
280
  return null;
281
281
  }
282
+ let sheetHref = s.href;
283
+ if (!sheetHref && s.ownerNode && s.ownerNode.ownerDocument) {
284
+ sheetHref = s.ownerNode.ownerDocument.baseURI;
285
+ }
282
286
  const stringifiedRules = Array.from(
283
287
  rules,
284
- (rule2) => stringifyRule(rule2, s.href)
288
+ (rule2) => stringifyRule(rule2, sheetHref)
285
289
  ).join("");
286
290
  return fixBrowserCompatibilityIssuesInCSS(stringifiedRules);
287
291
  } catch (error) {
@@ -289,6 +293,7 @@ function stringifyStylesheet(s) {
289
293
  }
290
294
  }
291
295
  function stringifyRule(rule2, sheetHref) {
296
+ var _a;
292
297
  if (isCSSImportRule(rule2)) {
293
298
  let importStringified;
294
299
  try {
@@ -299,8 +304,11 @@ function stringifyRule(rule2, sheetHref) {
299
304
  } catch (error) {
300
305
  importStringified = rule2.cssText;
301
306
  }
302
- if (rule2.styleSheet.href) {
303
- return absolutifyURLs(importStringified, rule2.styleSheet.href);
307
+ try {
308
+ if (importStringified && ((_a = rule2.styleSheet) == null ? void 0 : _a.href)) {
309
+ return absolutifyURLs(importStringified, rule2.styleSheet.href);
310
+ }
311
+ } catch (e) {
304
312
  }
305
313
  return importStringified;
306
314
  } else {
@@ -5454,6 +5462,16 @@ function createCache() {
5454
5462
  stylesWithHoverClass
5455
5463
  };
5456
5464
  }
5465
+ function safeDocNode(n, options) {
5466
+ let stringContent = n.textContent;
5467
+ if (n.isStyle && options.hackCss) {
5468
+ try {
5469
+ stringContent = adaptCssForReplay(n.textContent, options.cache);
5470
+ } catch (e) {
5471
+ }
5472
+ }
5473
+ return options.doc.createTextNode(stringContent);
5474
+ }
5457
5475
  function buildNode(n, options) {
5458
5476
  var _a;
5459
5477
  const { doc, hackCss, cache } = options;
@@ -5602,9 +5620,11 @@ function buildNode(n, options) {
5602
5620
  return node2;
5603
5621
  }
5604
5622
  case NodeType$1.Text:
5605
- return doc.createTextNode(
5606
- n.isStyle && hackCss ? adaptCssForReplay(n.textContent, cache) : n.textContent
5607
- );
5623
+ return safeDocNode(n, {
5624
+ cache,
5625
+ doc,
5626
+ hackCss
5627
+ });
5608
5628
  case NodeType$1.CDATA:
5609
5629
  if (n.textContent.trim() === "") {
5610
5630
  return null;