Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/core/main.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,17 @@ function withOverridesComparator (shorthandData) {
if (shorthandData[a] && shorthandData[a].includes(b)) return 0;
if (shorthandData[b] && shorthandData[b].includes(a)) return 0;

// This is necessary when two shorthands have matching longhands
Comment thread
Goodwine marked this conversation as resolved.
// without either shorthand being a longhand of the other.
// e.g. `text-wrap` and `white-space` both control `text-wrap-mode`.
if (
shorthandData[a] &&
shorthandData[b] &&
shorthandData[a].some(prop => shorthandData[b].includes(prop))
) {
return 0;
}

return comparator(a, b);
};
};
Expand Down
6 changes: 6 additions & 0 deletions src/core/main.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,12 @@ const keepOverridesTests = [
expected: 'a{border-radius: 5px;border-end-end-radius: 0;border-end-start-radius: 0;}',
options: { keepOverrides: true },
},
{
message: 'Keep text-wrap and white-space in authored order.',
fixture: 'a{white-space: pre;text-wrap: wrap;}',
expected: 'a{white-space: pre;text-wrap: wrap;}',
options: { keepOverrides: true },
},
];

testCssFixtures('Should order declarations.', sortOrderTests);
Expand Down
4 changes: 4 additions & 0 deletions src/core/shorthand-data.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,10 @@ export const shorthandData = {
'text-wrap-mode',
'text-wrap-style',
],
'white-space': [
Comment thread
Goodwine marked this conversation as resolved.
'white-space-collapse',
'text-wrap-mode',
],
'transition': [
'transition-delay',
'transition-duration',
Expand Down
Loading