(style: Record<string, string>)
| 456 | } |
| 457 | |
| 458 | function getBorderWidth(style: Record<string, string>): string | null { |
| 459 | if (style.border) { |
| 460 | const parsed = parseBorderShorthand(normalizeStyleValue(style.border)) |
| 461 | if (parsed.width) { |
| 462 | return normalizeStyleValue(parsed.width) |
| 463 | } |
| 464 | } |
| 465 | |
| 466 | if (style['border-width']) { |
| 467 | return normalizeStyleValue(style['border-width']) |
| 468 | } |
| 469 | |
| 470 | const sideWidths = BORDER_SIDES.map((side) => { |
| 471 | const width = style[`border-${side}-width`] |
| 472 | if (width) return normalizeStyleValue(width) |
| 473 | |
| 474 | const border = style[`border-${side}`] |
| 475 | if (!border) return null |
| 476 | |
| 477 | const parsed = parseBorderShorthand(normalizeStyleValue(border)) |
| 478 | return parsed.width ? normalizeStyleValue(parsed.width) : null |
| 479 | }) |
| 480 | |
| 481 | if (sideWidths.every((width): width is string => typeof width === 'string' && width.length > 0)) { |
| 482 | const [first, ...rest] = sideWidths |
| 483 | if (rest.every((width) => width === first)) { |
| 484 | return first |
| 485 | } |
| 486 | } |
| 487 | |
| 488 | return null |
| 489 | } |
| 490 | |
| 491 | function isZeroBorderWidth(value: string): boolean { |
| 492 | return ZERO_BORDER_WIDTH_RE.test(normalizeStyleValue(value).toLowerCase()) |
no test coverage detected