MCPcopy Create free account
hub / github.com/darkreader/darkreader / isStyleRule

Function isStyleRule

src/inject/dynamic-theme/css-rules.ts:183–197  ·  view source on GitHub ↗
(rule: CSSRule | null)

Source from the content-addressed store, hash-verified

181const layerRules = new WeakSet<CSSRule>();
182
183export function isStyleRule(rule: CSSRule | null): rule is CSSStyleRule {
184 if (!rule) {
185 return false;
186 }
187 if (styleRules.has(rule)) {
188 return true;
189 }
190 // Duck typing is faster than instanceof
191 // https://jsben.ch/B0eLa
192 if ((rule as CSSStyleRule).selectorText) {
193 styleRules.add(rule);
194 return true;
195 }
196 return false;
197}
198
199export function isImportRule(rule: CSSRule | null): rule is CSSImportRule {
200 if (!rule) {

Callers 3

createTargetFunction · 0.90
iterateCSSRulesFunction · 0.85
handleEmptyShorthandFunction · 0.85

Calls 2

addMethod · 0.80
hasMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…