Skip to content

Commit 89f6af4

Browse files
committed
1 parent abc8426 commit 89f6af4

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

packages/rrweb-snapshot/src/utils.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,17 @@ export function stringifyRule(rule: CSSRule, sheetHref: string | null): string {
130130
} catch (error) {
131131
importStringified = rule.cssText;
132132
}
133-
if (rule.styleSheet.href) {
134-
// url()s within the imported stylesheet are relative to _that_ sheet's href
135-
return absolutifyURLs(importStringified, rule.styleSheet.href);
133+
// if importStringified is not null,
134+
// there should be a stylesheet and a rule here,
135+
// but we avoid errors in this method by checking for null
136+
// see https://github.com/rrweb-io/rrweb/pull/1686
137+
try {
138+
if (importStringified && rule.styleSheet?.href) {
139+
// url()s within the imported stylesheet are relative to _that_ sheet's href
140+
return absolutifyURLs(importStringified, rule.styleSheet.href);
141+
}
142+
} catch {
143+
// swallow this, we'll return null
136144
}
137145
return importStringified;
138146
} else {

0 commit comments

Comments
 (0)