Skip to content
Closed
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ This project adheres to [Semantic Versioning](https://semver.org/).
## Unreleased

* Fixed `order`: an at-rule pattern with `parameter` no longer matches at-rules that have no parameters.
* Fixed `properties-order: 'alphabetical'`: `gap`, `place-content`, `place-items`, `place-self` and `contain-intrinsic-size` are now sorted before their longhands. Also added `font-variant`, `font-synthesis`, `scroll-margin`, `scroll-padding` and `text-decoration-thickness` to the shorthand list.
* Improved performance. Sorting is about 2x to 10x faster depending on the stylesheet: roughly 4–5× on typical CSS using both `order` and `properties-order`, and more on large rules or stylesheets with many rules or comments

## 10.0.0
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
a {
column-gap: 2px;
gap: 1px;
}

a {
justify-content: end;
align-content: start;
place-content: center;
}

a {
justify-items: end;
place-items: center;
align-items: start;
}

a {
align-self: start;
place-self: center;
justify-self: end;
}

a {
contain-intrinsic-width: 30px;
contain-intrinsic-height: 20px;
contain-intrinsic-size: 10px;
}

a {
gap: 1px;
row-gap: 3px;
column-gap: 2px;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
a {
gap: 1px;
column-gap: 2px;
}

a {
place-content: center;
align-content: start;
justify-content: end;
}

a {
place-items: center;
align-items: start;
justify-items: end;
}

a {
place-self: center;
align-self: start;
justify-self: end;
}

a {
contain-intrinsic-size: 10px;
contain-intrinsic-height: 20px;
contain-intrinsic-width: 30px;
}

a {
gap: 1px;
column-gap: 2px;
row-gap: 3px;
}
16 changes: 16 additions & 0 deletions lib/properties-order/__tests__/isShorthand.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,19 @@ test('border-inline is shorthand for border-top-color', () => {
test('border-top-color is not shorthand for border-inline', () => {
expect(isShorthand('border-top-color', 'border-inline')).toBe(false);
});

test.each([
['gap', 'column-gap'],
['place-content', 'justify-content'],
['place-items', 'align-items'],
['place-self', 'justify-self'],
['contain-intrinsic-size', 'contain-intrinsic-width'],
['font', 'font-variant-caps'],
['font-synthesis', 'font-synthesis-weight'],
['scroll-margin', 'scroll-margin-top'],
['scroll-padding-inline', 'scroll-padding-inline-end'],
['text-decoration', 'text-decoration-thickness'],
])('%s is shorthand for %s', (shorthand, longhand) => {
expect(isShorthand(shorthand, longhand)).toBe(true);
expect(isShorthand(longhand, shorthand)).toBe(false);
});
5 changes: 5 additions & 0 deletions lib/properties-order/__tests__/properties-order.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ test('Should sort shorthand properties before their longhand versions', () =>
'properties-order': 'alphabetical',
}));

test('Should sort gap, place-* and contain-intrinsic-size before their longhands', () =>
runTest('properties-alphabetical-shorthand-modern', {
'properties-order': 'alphabetical',
}));

test('Should sort prefixed properties before unprefixed property in alphabetical order', () =>
runTest('prefixed-alphabetical', {
'properties-order': 'alphabetical',
Expand Down
42 changes: 41 additions & 1 deletion lib/properties-order/shorthandData.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,10 @@ export const shorthandData = {
'grid-area': ['grid-row-start', 'grid-column-start', 'grid-row-end', 'grid-column-end'],
'grid-column': ['grid-column-start', 'grid-column-end'],
'grid-gap': ['grid-row-gap', 'grid-column-gap'],
gap: ['row-gap', 'column-gap'],
'place-content': ['align-content', 'justify-content'],
'place-items': ['align-items', 'justify-items'],
'place-self': ['align-self', 'justify-self'],
'grid-row': ['grid-row-start', 'grid-row-end'],
'grid-template': ['grid-template-columns', 'grid-template-rows', 'grid-template-areas'],
offset: ['offset-anchor', 'offset-distance', 'offset-path', 'offset-position', 'offset-rotate'],
Expand All @@ -296,7 +300,12 @@ export const shorthandData = {
],
'overscroll-behavior-block': ['overscroll-behavior-x', 'overscroll-behavior-y'],
'overscroll-behavior-inline': ['overscroll-behavior-x', 'overscroll-behavior-y'],
'text-decoration': ['text-decoration-color', 'text-decoration-style', 'text-decoration-line'],
'text-decoration': [
'text-decoration-color',
'text-decoration-style',
'text-decoration-line',
'text-decoration-thickness',
],
'text-emphasis': ['text-emphasis-style', 'text-emphasis-color'],
mask: [
'mask-image',
Expand All @@ -323,4 +332,35 @@ export const shorthandData = {
'inset-block-end': ['top', 'bottom', 'left', 'right'],
'inset-inline-start': ['top', 'bottom', 'left', 'right'],
'inset-inline-end': ['top', 'bottom', 'left', 'right'],
'contain-intrinsic-size': ['contain-intrinsic-width', 'contain-intrinsic-height'],
'font-synthesis': [
'font-synthesis-weight',
'font-synthesis-style',
'font-synthesis-small-caps',
],
'font-variant': [
'font-variant-ligatures',
'font-variant-position',
'font-variant-caps',
'font-variant-numeric',
'font-variant-alternates',
'font-variant-east-asian',
'font-variant-emoji',
],
'scroll-margin': [
'scroll-margin-top',
'scroll-margin-right',
'scroll-margin-bottom',
'scroll-margin-left',
],
'scroll-margin-block': ['scroll-margin-block-start', 'scroll-margin-block-end'],
'scroll-margin-inline': ['scroll-margin-inline-start', 'scroll-margin-inline-end'],
'scroll-padding': [
'scroll-padding-top',
'scroll-padding-right',
'scroll-padding-bottom',
'scroll-padding-left',
],
'scroll-padding-block': ['scroll-padding-block-start', 'scroll-padding-block-end'],
'scroll-padding-inline': ['scroll-padding-inline-start', 'scroll-padding-inline-end'],
};