Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | import { BaseSelectorProcessor } from './base-processor.js';
export type AllSelectorsProcessorResults = string[];
/**
* Processor for extracting all CSS selectors
*/
export class AllSelectorsProcessor extends BaseSelectorProcessor<AllSelectorsProcessorResults> {
protected selectorSet = new Set<string>();
constructor(skipEmptyRules: boolean = true) {
super(skipEmptyRules);
}
/**
* Process a selector node
* @param selector The selector node to process
*/
protected processSelectorNode(selector: any): void {
// Check if the selector is a class selector
if (selector.type === 'class' && selector.value.startsWith('slds-')) {
const selectorValue = selector.value;
// Add to our array if not already present
this.selectorSet.add(selectorValue);
}
}
/**
* Get the results of processing
* @returns The array of selectors
*/
getResults(): AllSelectorsProcessorResults {
return Array.from(this.selectorSet).sort((a, b) => a.localeCompare(b));
}
} |