(cssDeclarationsText: string)
| 95 | } |
| 96 | |
| 97 | function parseDeclarations(cssDeclarationsText: string) { |
| 98 | const declarations: ParsedDeclaration[] = []; |
| 99 | const excludeRanges = getTokenExclusionRanges(cssDeclarationsText); |
| 100 | splitExcluding(cssDeclarationsText, ';', excludeRanges).forEach((part) => { |
| 101 | const colonIndex = part.indexOf(':'); |
| 102 | if (colonIndex > 0) { |
| 103 | const importantIndex = part.indexOf('!important'); |
| 104 | declarations.push({ |
| 105 | property: part.substring(0, colonIndex).trim(), |
| 106 | value: part.substring(colonIndex + 1, importantIndex > 0 ? importantIndex : part.length).trim(), |
| 107 | important: importantIndex > 0, |
| 108 | }); |
| 109 | } |
| 110 | }); |
| 111 | return declarations; |
| 112 | } |
| 113 | |
| 114 | export function isParsedStyleRule(rule: ParsedAtRule | ParsedStyleRule): rule is ParsedStyleRule { |
| 115 | return 'selectors' in rule; |
no test coverage detected