(css: string, selector: string)
| 69 | } |
| 70 | |
| 71 | function extractBlock(css: string, selector: string): string | null { |
| 72 | const cssWithoutComments = stripCssComments(css); |
| 73 | for (const match of cssWithoutComments.matchAll(/([^{}]+)\{([^{}]*)\}/g)) { |
| 74 | const selectorList = match[1]; |
| 75 | const block = match[2]; |
| 76 | if (selectorList === undefined || block === undefined) { |
| 77 | continue; |
| 78 | } |
| 79 | |
| 80 | const selectors = selectorList.split(",").map((value) => value.trim()); |
| 81 | if (selectors.includes(selector)) { |
| 82 | return block; |
| 83 | } |
| 84 | } |
| 85 | return null; |
| 86 | } |
| 87 | |
| 88 | function extractVariable(block: string, variable: string): string | null { |
| 89 | return extractVariables(block).get(variable) ?? null; |
no test coverage detected