| 690 | } |
| 691 | |
| 692 | const applyBorderStyles = ( |
| 693 | node: LayoutNode, |
| 694 | style: Styles, |
| 695 | resolvedStyle?: Styles, |
| 696 | ): void => { |
| 697 | // resolvedStyle is the full current style (already set on the DOM node). |
| 698 | // style may be a diff with only changed properties. For border side props, |
| 699 | // we need the resolved value because `borderStyle` in a diff may not include |
| 700 | // unchanged border side values (e.g. borderTop stays false but isn't in the diff). |
| 701 | const resolved = resolvedStyle ?? style |
| 702 | |
| 703 | if ('borderStyle' in style) { |
| 704 | const borderWidth = style.borderStyle ? 1 : 0 |
| 705 | |
| 706 | node.setBorder( |
| 707 | LayoutEdge.Top, |
| 708 | resolved.borderTop !== false ? borderWidth : 0, |
| 709 | ) |
| 710 | node.setBorder( |
| 711 | LayoutEdge.Bottom, |
| 712 | resolved.borderBottom !== false ? borderWidth : 0, |
| 713 | ) |
| 714 | node.setBorder( |
| 715 | LayoutEdge.Left, |
| 716 | resolved.borderLeft !== false ? borderWidth : 0, |
| 717 | ) |
| 718 | node.setBorder( |
| 719 | LayoutEdge.Right, |
| 720 | resolved.borderRight !== false ? borderWidth : 0, |
| 721 | ) |
| 722 | } else { |
| 723 | // Handle individual border property changes (when only borderX changes without borderStyle). |
| 724 | // Skip undefined values — they mean the prop was removed or never set, |
| 725 | // not that a border should be enabled. |
| 726 | if ('borderTop' in style && style.borderTop !== undefined) { |
| 727 | node.setBorder(LayoutEdge.Top, style.borderTop === false ? 0 : 1) |
| 728 | } |
| 729 | if ('borderBottom' in style && style.borderBottom !== undefined) { |
| 730 | node.setBorder(LayoutEdge.Bottom, style.borderBottom === false ? 0 : 1) |
| 731 | } |
| 732 | if ('borderLeft' in style && style.borderLeft !== undefined) { |
| 733 | node.setBorder(LayoutEdge.Left, style.borderLeft === false ? 0 : 1) |
| 734 | } |
| 735 | if ('borderRight' in style && style.borderRight !== undefined) { |
| 736 | node.setBorder(LayoutEdge.Right, style.borderRight === false ? 0 : 1) |
| 737 | } |
| 738 | } |
| 739 | } |
| 740 | |
| 741 | const applyGapStyles = (node: LayoutNode, style: Styles): void => { |
| 742 | if ('gap' in style) { |