Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Code style: more compact
  • Loading branch information
eoghanmurray authored and jeffdnguyen committed Jul 19, 2024
commit acf1cb9e7d8c7c418aa547f969a487619e64d274
26 changes: 11 additions & 15 deletions packages/rrweb-snapshot/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,27 +121,23 @@ export function stringifyRule(rule: CSSRule, sheetHref: string | null): string {
} catch (error) {
importStringified = rule.cssText;
}

if (rule.styleSheet.href) {
// url()s within the imported stylesheet are relative to _that_ sheet's href
return absolutifyURLs(importStringified, rule.styleSheet.href);
}

return importStringified;
} else {
let ruleStringified = rule.cssText;
if (isCSSStyleRule(rule) && rule.selectorText.includes(':')) {
// Safari does not escape selectors with : properly
// see https://bugs.webkit.org/show_bug.cgi?id=184604
ruleStringified = fixSafariColons(ruleStringified);
}
if (sheetHref) {
return absolutifyURLs(ruleStringified, sheetHref);
}
return ruleStringified;
}

let ruleStringified = rule.cssText;
if (isCSSStyleRule(rule) && rule.selectorText.includes(':')) {
// Safari does not escape selectors with : properly
// see https://bugs.webkit.org/show_bug.cgi?id=184604
ruleStringified = fixSafariColons(ruleStringified);
}

if (sheetHref) {
return absolutifyURLs(ruleStringified, sheetHref);
}

return ruleStringified;
}

export function fixSafariColons(cssStringified: string): string {
Expand Down