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