Use node.baseURI for stringifying stylesheet hrefs (#1705)

This commit is contained in:
Meg Boehlert
2025-09-05 05:12:27 -04:00
committed by GitHub
parent 0bceef6a15
commit f2419f2513
3 changed files with 52 additions and 2 deletions

View File

@@ -118,9 +118,9 @@ export function stringifyStylesheet(s: CSSStyleSheet): string | null {
return null;
}
let sheetHref = s.href;
if (!sheetHref && s.ownerNode && s.ownerNode.ownerDocument) {
if (!sheetHref && s.ownerNode) {
// an inline <style> element
sheetHref = s.ownerNode.ownerDocument.location.href;
sheetHref = s.ownerNode.baseURI;
}
const stringifiedRules = Array.from(rules, (rule: CSSRule) =>
stringifyRule(rule, sheetHref),