(styles: string)
| 181 | * @param {string} styles Tokenized styles to split. |
| 182 | */ |
| 183 | export function splitStyles(styles: string): ThemableArray { |
| 184 | const result: ThemableArray = []; |
| 185 | if (styles) { |
| 186 | let pos: number = 0; // Current position in styles. |
| 187 | let tokenMatch: RegExpExecArray; |
| 188 | while (tokenMatch = _themeTokenRegex.exec(styles)) { |
| 189 | const matchIndex: number = tokenMatch.index; |
| 190 | if (matchIndex > pos) { |
| 191 | result.push({ |
| 192 | rawString: styles.substring(pos, matchIndex) |
| 193 | }); |
| 194 | } |
| 195 | |
| 196 | result.push({ |
| 197 | theme: tokenMatch[1], |
| 198 | defaultValue: tokenMatch[2] // May be undefined |
| 199 | }); |
| 200 | |
| 201 | // index of the first character after the current match |
| 202 | pos = _themeTokenRegex.lastIndex; |
| 203 | } |
| 204 | |
| 205 | // Push the rest of the string after the last match. |
| 206 | result.push({ |
| 207 | rawString: styles.substring(pos) |
| 208 | }); |
| 209 | } |
| 210 | |
| 211 | return result; |
| 212 | } |
| 213 | |
| 214 | /** |
| 215 | * Registers a set of style text. If it is registered too early, we will register it when the |
no outgoing calls
no test coverage detected