Skip to content

Commit

Permalink
Fix regression on test [html file]: with-style-sheet-with-import.html
Browse files Browse the repository at this point in the history
The prior 'dynamic stylesheet' route is now the main route for serializing a stylesheet; dynamic stylesheet were missed out in rrweb-io#1533 but are caught in this PR by the tests added in that PR as the stylesheet handling is simplified/centralised
  • Loading branch information
eoghanmurray committed Jul 26, 2024
1 parent b160a2c commit 19efe58
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/rrweb-snapshot/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,13 @@ export function stringifyStylesheet(s: CSSStyleSheet): string | null {
if (!rules) {
return null;
}
let sheetHref = s.href;
if (!sheetHref && s.ownerNode && s.ownerNode.ownerDocument) {
// an inline <style> element
sheetHref = s.ownerNode.ownerDocument.location.href;
}
const stringifiedRules = Array.from(rules, (rule: CSSRule) =>
stringifyRule(rule, s.href),
stringifyRule(rule, sheetHref),
).join('');
return fixBrowserCompatibilityIssuesInCSS(stringifiedRules);
} catch (error) {
Expand Down

0 comments on commit 19efe58

Please sign in to comment.