(context: Context, descriptor: CSSPropertyDescriptor<any>, style?: string | null)
| 285 | |
| 286 | // eslint-disable-next-line @typescript-eslint/no-explicit-any |
| 287 | const parse = (context: Context, descriptor: CSSPropertyDescriptor<any>, style?: string | null) => { |
| 288 | const tokenizer = new Tokenizer(); |
| 289 | const value = style !== null && typeof style !== 'undefined' ? style.toString() : descriptor.initialValue; |
| 290 | tokenizer.write(value); |
| 291 | const parser = new Parser(tokenizer.read()); |
| 292 | switch (descriptor.type) { |
| 293 | case PropertyDescriptorParsingType.IDENT_VALUE: |
| 294 | const token = parser.parseComponentValue(); |
| 295 | return descriptor.parse(context, isIdentToken(token) ? token.value : descriptor.initialValue); |
| 296 | case PropertyDescriptorParsingType.VALUE: |
| 297 | return descriptor.parse(context, parser.parseComponentValue()); |
| 298 | case PropertyDescriptorParsingType.LIST: |
| 299 | return descriptor.parse(context, parser.parseComponentValues()); |
| 300 | case PropertyDescriptorParsingType.TOKEN_VALUE: |
| 301 | return parser.parseComponentValue(); |
| 302 | case PropertyDescriptorParsingType.TYPE_VALUE: |
| 303 | switch (descriptor.format) { |
| 304 | case 'angle': |
| 305 | return angle.parse(context, parser.parseComponentValue()); |
| 306 | case 'color': |
| 307 | return colorType.parse(context, parser.parseComponentValue()); |
| 308 | case 'image': |
| 309 | return image.parse(context, parser.parseComponentValue()); |
| 310 | case 'length': |
| 311 | const length = parser.parseComponentValue(); |
| 312 | return isLength(length) ? length : ZERO_LENGTH; |
| 313 | case 'length-percentage': |
| 314 | const value = parser.parseComponentValue(); |
| 315 | return isLengthPercentage(value) ? value : ZERO_LENGTH; |
| 316 | case 'time': |
| 317 | return time.parse(context, parser.parseComponentValue()); |
| 318 | } |
| 319 | break; |
| 320 | } |
| 321 | }; |
no test coverage detected
searching dependent graphs…