(selector: string, type: keyof typeof filterSelectors)
| 7 | }; |
| 8 | |
| 9 | export function addFilterSelector(selector: string, type: keyof typeof filterSelectors) { |
| 10 | if (!selector) { |
| 11 | return; |
| 12 | } |
| 13 | const selectors = filterSelectors[type]; |
| 14 | let changed = false; |
| 15 | selector.split(',').forEach((part) => { |
| 16 | const s = part.trim(); |
| 17 | if (!s || selectors.has(s)) { |
| 18 | return; |
| 19 | } |
| 20 | for (const existing of selectors) { |
| 21 | if (isSelectorWithin(s, existing)) { |
| 22 | return; |
| 23 | } |
| 24 | } |
| 25 | for (const existing of [...selectors]) { |
| 26 | if (isSelectorWithin(existing, s)) { |
| 27 | selectors.delete(existing); |
| 28 | } |
| 29 | } |
| 30 | selectors.add(s); |
| 31 | changed = true; |
| 32 | }); |
| 33 | return changed; |
| 34 | } |
| 35 | |
| 36 | export function makeSelectorEmpty(selector: string) { |
| 37 | selector = selector.trim(); |
no test coverage detected