Skip to content

Commit 94ebe8c

Browse files
committed
Refactor border shorthand generation functions
Renamed generateBorderNameShorthand to generateBorderShorthand and updated related variable names for clarity. This improves code readability and better reflects the function's purpose.
1 parent 37ff437 commit 94ebe8c

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

lib/normalize.js

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,14 +1091,14 @@ const generateBorderPositionShorthand = (items, property, priority = "") => {
10911091
};
10921092

10931093
/**
1094-
* Generates a border name shorthand property if all components match.
1094+
* Generates a border shorthand property if all components match.
10951095
*
1096-
* @param {Set|Array} items - The collection of property values.
1096+
* @param {Array} items - The collection of property values.
10971097
* @param {string} property - The shorthand property name to generate.
10981098
* @param {string} [priority=""] - The priority of the property.
10991099
* @returns {Array|undefined} A key-value pair for the generated property or undefined.
11001100
*/
1101-
const generateBorderNameShorthand = (items, property, priority = "") => {
1101+
const generateBorderShorthand = (items, property, priority = "") => {
11021102
const values = new Set(items);
11031103
if (values.size === 1) {
11041104
const value = values.keys().next().value;
@@ -1185,8 +1185,8 @@ const prepareBorderShorthands = (properties) => {
11851185
}
11861186
}
11871187
}
1188-
const nameItems = [];
1189-
const namePriorityItems = [];
1188+
const shorthandItems = [];
1189+
const shorthandPriorityItems = [];
11901190
for (const [key, collection] of Object.entries(borderCollections)) {
11911191
const { shorthand, generator, items, priorityItems } = collection;
11921192
const requiredSize = borderLines.has(key) ? 4 : 3;
@@ -1197,7 +1197,7 @@ const prepareBorderShorthands = (properties) => {
11971197
if (borderPositions.has(key) && properties.has(BORDER_IMAGE)) {
11981198
const { value: imageValue } = properties.get(BORDER_IMAGE);
11991199
if (imageValue === NONE) {
1200-
nameItems.push(item.value);
1200+
shorthandItems.push(item.value);
12011201
}
12021202
}
12031203
}
@@ -1208,24 +1208,23 @@ const prepareBorderShorthands = (properties) => {
12081208
if (borderPositions.has(key) && properties.has(BORDER_IMAGE)) {
12091209
const { value: imageValue } = properties.get(BORDER_IMAGE);
12101210
if (imageValue === NONE) {
1211-
namePriorityItems.push(item.value);
1211+
shorthandPriorityItems.push(item.value);
12121212
}
12131213
}
12141214
}
12151215
}
12161216
}
1217-
const mixedPriorities = nameItems.length && namePriorityItems.length;
1217+
const mixedPriorities = shorthandItems.length && shorthandPriorityItems.length;
12181218
const imageItem = createPropertyItem(BORDER_IMAGE, NONE);
1219-
if (nameItems.length === 4) {
1220-
const [property, item] = generateBorderNameShorthand(nameItems, BORDER) ?? [];
1219+
if (shorthandItems.length === 4) {
1220+
const [property, item] = generateBorderShorthand(shorthandItems, BORDER) ?? [];
12211221
if (property && item) {
12221222
properties.set(property, item);
12231223
properties.delete(BORDER_IMAGE);
12241224
properties.set(BORDER_IMAGE, imageItem);
12251225
}
1226-
} else if (namePriorityItems.length === 4) {
1227-
const [property, item] =
1228-
generateBorderNameShorthand(namePriorityItems, BORDER, "important") ?? [];
1226+
} else if (shorthandPriorityItems.length === 4) {
1227+
const [property, item] = generateBorderShorthand(shorthandPriorityItems, BORDER, "important") ?? [];
12291228
if (property && item) {
12301229
properties.set(property, item);
12311230
properties.delete(BORDER_IMAGE);

0 commit comments

Comments
 (0)