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

Function isSelectorWithin

src/inject/dynamic-theme/selectors.ts:44–65  ·  view source on GitHub ↗
(sub: string, parent: string)

Source from the content-addressed store, hash-verified

42}
43
44export function isSelectorWithin(sub: string, parent: string): boolean {
45 const parentLength = parent.length;
46 const subLength = sub.length;
47 if (subLength < parentLength || !sub.startsWith(parent)) {
48 return false;
49 }
50 if (subLength === parentLength) {
51 return true;
52 }
53 let i = parentLength;
54 const c = sub[i];
55 if (c === '.' || c === ':' || c === '#' || c === '[' || c === '>') {
56 return true;
57 }
58 if (c === '+' || c === '~' || c !== ' ') {
59 return false;
60 }
61 while (sub[i] === ' ') {
62 i++;
63 }
64 return sub[i] !== '+' && sub[i] !== '~';
65}
66
67export function cleanFilterSelectors() {
68 filterSelectors.invert.clear();

Callers 2

selectors.tests.tsFile · 0.90
addFilterSelectorFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…