Skip to content

Commit

Permalink
Code style: more compact
Browse files Browse the repository at this point in the history
  • Loading branch information
eoghanmurray committed Jul 19, 2024
1 parent babd20a commit 0be0dc2
Showing 1 changed file with 11 additions and 15 deletions.
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

0 comments on commit 0be0dc2

Please sign in to comment.