@@ -112,6 +112,23 @@ const getPropertyItem = (property, properties) => {
112112 return propertyItem ;
113113} ;
114114
115+ /**
116+ * Retrieves a property item from borderItems, properties, or creates a new one.
117+ * Prioritizes borderItems (processed items) over properties (existing items).
118+ *
119+ * @param {string } property - The name of the property.
120+ * @param {Map } borderItems - The map containing processed border items.
121+ * @param {Map } properties - The map containing all properties.
122+ * @returns {Object } The property item.
123+ */
124+ const getBorderItem = ( property , borderItems , properties ) => {
125+ return (
126+ borderItems . get ( property ) ??
127+ properties . get ( property ) ??
128+ createPropertyItem ( property )
129+ ) ;
130+ } ;
131+
115132/**
116133 * Calculates the value for a specific position (top, right, bottom, left)
117134 * based on the array of values provided for a shorthand property.
@@ -1030,29 +1047,20 @@ const prepareBorderProperties = (property, value, priority, properties, opt = {}
10301047 const borderProps = new Map ( [ [ BORDER , borderItems . get ( BORDER ) ] ] ) ;
10311048 for ( const line of borderLines ) {
10321049 const lineProperty = `${ BORDER } -${ line } ` ;
1033- const lineItem =
1034- borderItems . get ( lineProperty ) ??
1035- properties . get ( lineProperty ) ??
1036- createPropertyItem ( lineProperty ) ;
1050+ const lineItem = getBorderItem ( lineProperty , borderItems , properties ) ;
10371051 borderProps . set ( lineProperty , lineItem ) ;
10381052 }
10391053 for ( const position of borderPositions ) {
10401054 const positionProperty = `${ BORDER } -${ position } ` ;
1041- const positionItem =
1042- borderItems . get ( positionProperty ) ??
1043- properties . get ( positionProperty ) ??
1044- createPropertyItem ( positionProperty ) ;
1055+ const positionItem = getBorderItem ( positionProperty , borderItems , properties ) ;
10451056 borderProps . set ( positionProperty , positionItem ) ;
10461057 for ( const line of borderLines ) {
10471058 const longhandProperty = `${ BORDER } -${ position } -${ line } ` ;
1048- const longhandItem =
1049- borderItems . get ( longhandProperty ) ??
1050- properties . get ( longhandProperty ) ??
1051- createPropertyItem ( longhandProperty ) ;
1059+ const longhandItem = getBorderItem ( longhandProperty , borderItems , properties ) ;
10521060 borderProps . set ( longhandProperty , longhandItem ) ;
10531061 }
10541062 }
1055- const borderImageItem = borderItems . get ( BORDER_IMAGE ) ?? createPropertyItem ( BORDER_IMAGE ) ;
1063+ const borderImageItem = getBorderItem ( BORDER_IMAGE , borderItems , properties ) ;
10561064 borderProps . set ( BORDER_IMAGE , borderImageItem ) ;
10571065 return borderProps ;
10581066} ;
0 commit comments