Preserve unresolved linked CSS selectors

AI assistance disclosure: Codex implemented and verified this fix under maintainer direction.
This commit is contained in:
Paul Bakaus
2026-09-02 09:30:26 -07:00
parent 45148003af
commit 0fa4202ca9
4 changed files with 30 additions and 2 deletions
+6 -1
View File
@@ -1332,7 +1332,12 @@ if (IS_BROWSER) {
}
const cssText = rule.cssText || '';
if (rule.selectorText) {
if (selectorNodesForLiveDom(document, rule.selectorText)?.length > 0) parts.push(cssText);
const matches = selectorNodesForLiveDom(document, rule.selectorText);
// A null result means the DOM selector API cannot resolve the CSSOM
// selector (commonly a hostless pseudo-element), not that it is
// unused. Keep those valid stylesheet rules; only a definitive empty
// result proves that no live element can receive the declaration.
if (matches === null || matches.length > 0) parts.push(cssText);
continue;
}
let nested = [];