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

This commit is contained in:
Meg Boehlert
2026-04-01 12:00:00 +08:00
committed by GitHub
parent dda4736d33
commit 87ff67b978
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),