Skip to content

Commit 1597155

Browse files
committed
Merge remote-tracking branch 'origin/main' into postcss-preset-env--v8
2 parents 0878904 + 483f85c commit 1597155

File tree

176 files changed

+1236
-427
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

176 files changed

+1236
-427
lines changed

.github/labeler.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,9 @@
164164
- plugins/postcss-pseudo-class-any-link/**
165165
- experimental/postcss-pseudo-class-any-link/**
166166

167-
"plugins/postcss-rebeccapurple":
168-
- plugins/postcss-rebeccapurple/**
169-
- experimental/postcss-rebeccapurple/**
167+
"plugins/postcss-color-rebeccapurple":
168+
- plugins/postcss-color-rebeccapurple/**
169+
- experimental/postcss-color-rebeccapurple/**
170170

171171
"plugins/postcss-replace-overflow-wrap":
172172
- plugins/postcss-replace-overflow-wrap/**

package-lock.json

+6-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/selector-specificity/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changes to Selector Specificity
22

3+
### Unreleased
4+
5+
- Fix case insensitive matching.
6+
37
### 2.0.1 (June 10, 2022)
48

59
- Fixed: Exception on `:nth-child` without arguments. [#439](https://github.com/csstools/postcss-plugins/issues/439)

packages/selector-specificity/src/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export function selectorSpecificity(node: Node): Specificity {
3939
} else if (isPseudoElement(node)) {
4040
c += 1;
4141
} else if (parser.isPseudoClass(node)) {
42-
switch (node.value) {
42+
switch (node.value.toLowerCase()) {
4343
case ':-moz-any':
4444
case ':-webkit-any':
4545
case ':any':
@@ -74,7 +74,7 @@ export function selectorSpecificity(node: Node): Specificity {
7474

7575
if (node.nodes && node.nodes.length > 0) {
7676
const ofSeparatorIndex = node.nodes[0].nodes.findIndex((x) => {
77-
return x.type === 'tag' && x.value === 'of';
77+
return x.type === 'tag' && x.value.toLowerCase() === 'of';
7878
});
7979

8080
if (ofSeparatorIndex > -1) {

plugin-packs/postcss-preset-env/test/basic.autoprefixer.expect.css

-1
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,6 @@
507507
text-indent: 2em;
508508
content: var(--value-2ic);
509509
left: 2em;
510-
left: 2em;
511510
left: var(--non-existing, 2em);
512511
width: calc(8em + 20px);
513512
height: 10px;

plugin-packs/postcss-preset-env/test/basic.autoprefixer.false.expect.css

-1
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,6 @@
507507
text-indent: 2em;
508508
content: var(--value-2ic);
509509
left: 2em;
510-
left: 2em;
511510
left: var(--non-existing, 2em);
512511
width: calc(8em + 20px);
513512
height: 10px;

plugin-packs/postcss-preset-env/test/basic.ch38.expect.css

-1
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,6 @@
427427
text-indent: 2em;
428428
content: var(--value-2ic);
429429
left: 2em;
430-
left: 2em;
431430
left: var(--non-existing, 2em);
432431
width: calc(8em + 20px);
433432
height: 10px;

plugin-packs/postcss-preset-env/test/basic.expect.css

-1
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,6 @@
530530
text-indent: 2em;
531531
content: var(--value-2ic);
532532
left: 2em;
533-
left: 2em;
534533
left: var(--non-existing, 2em);
535534
width: calc(8em + 20px);
536535
height: 10px;

plugin-packs/postcss-preset-env/test/basic.ie10.expect.css

-1
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,6 @@
545545
text-indent: 2em;
546546
content: var(--value-2ic);
547547
left: 2em;
548-
left: 2em;
549548
left: var(--non-existing, 2em);
550549
width: calc(8em + 20px);
551550
height: 10px;

plugin-packs/postcss-preset-env/test/basic.nesting.false.expect.css

-1
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,6 @@ h1.test-custom-selectors,h2.test-custom-selectors,h3.test-custom-selectors,h4.te
528528
text-indent: 2em;
529529
content: var(--value-2ic);
530530
left: 2em;
531-
left: 2em;
532531
left: var(--non-existing, 2em);
533532
width: calc(8em + 20px);
534533
height: 10px;

plugin-packs/postcss-preset-env/test/basic.op_mini.expect.css

-1
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,6 @@ h1.test-custom-selectors,h2.test-custom-selectors,h3.test-custom-selectors,h4.te
514514
text-indent: 2em;
515515
content: var(--value-2ic);
516516
left: 2em;
517-
left: 2em;
518517
left: var(--non-existing, 2em);
519518
width: calc(8em + 20px);
520519
height: 10px;

plugin-packs/postcss-preset-env/test/basic.preserve.true.expect.css

-1
Original file line numberDiff line numberDiff line change
@@ -921,7 +921,6 @@ h1.test-custom-selectors,h2.test-custom-selectors,h3.test-custom-selectors,h4.te
921921
-o-transform: rotate(mod(-140deg, -90deg));
922922
transform: rotate(mod(-140deg, -90deg));
923923
width: 2px;
924-
width: mod(2px, 5px);
925924
width: mod(mod(-18px, 5px), 5px);
926925
}
927926

plugin-packs/postcss-preset-env/test/basic.stage0.expect.css

-1
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,6 @@ h1.test-custom-selectors,h2.test-custom-selectors,h3.test-custom-selectors,h4.te
535535
text-indent: 2em;
536536
content: var(--value-2ic);
537537
left: 2em;
538-
left: 2em;
539538
left: var(--non-existing, 2em);
540539
width: calc(8em + 20px);
541540
height: 10px;

plugin-packs/postcss-preset-env/test/basic.vendors-1.expect.css

-1
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,6 @@
482482
text-indent: 2em;
483483
content: var(--value-2ic);
484484
left: 2em;
485-
left: 2em;
486485
left: var(--non-existing, 2em);
487486
width: calc(8em + 20px);
488487
height: 10px;

plugin-packs/postcss-preset-env/test/basic.vendors-2.expect.css

-1
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,6 @@
474474
text-indent: 2em;
475475
content: var(--value-2ic);
476476
left: 2em;
477-
left: 2em;
478477
left: var(--non-existing, 2em);
479478
width: calc(8em + 20px);
480479
height: 10px;

plugin-packs/postcss-preset-env/test/layers-basic.expect.css

-1
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,6 @@ h1.test-custom-selectors:not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):n
744744
text-indent: 2em;
745745
content: var(--value-2ic);
746746
left: 2em;
747-
left: 2em;
748747
left: var(--non-existing, 2em);
749748
width: -webkit-calc(8em + 20px);
750749
width: -moz-calc(8em + 20px);

plugin-packs/postcss-preset-env/test/layers-basic.preserve.true.expect.css

-1
Original file line numberDiff line numberDiff line change
@@ -932,7 +932,6 @@ h1.test-custom-selectors:not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):n
932932
-o-transform: rotate(mod(-140deg, -90deg));
933933
transform: rotate(mod(-140deg, -90deg));
934934
width: 2px;
935-
width: mod(2px, 5px);
936935
width: mod(mod(-18px, 5px), 5px);
937936
}
938937

Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
# Changes to PostCSS Attribute Case Insensitive
22

3-
## 5.0.1 (3 June, 2022)
3+
### Unreleased
4+
5+
- Fix incorrect selector AST updates
6+
7+
### 5.0.1 (3 June, 2022)
48

59
- Prevent exponential backtracking when checking for selectors with case insensitive value matching.
610

7-
## 5.0.0 (15 September, 2020)
11+
### 5.0.0 (15 September, 2020)
812

913
- Postcss 8.x support
1014

11-
## 4.0.1 (10 January, 2019)
15+
### 4.0.1 (10 January, 2019)
1216

13-
## 2.0.0 (06 May, 2017)
17+
### 2.0.0 (06 May, 2017)
1418

15-
## 1.0.1 (19 August, 2016)
19+
### 1.0.1 (19 August, 2016)
1620

17-
## 1.0.0 (10 August, 2016)
21+
### 1.0.0 (10 August, 2016)

plugins/postcss-attribute-case-insensitive/src/index.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,12 @@ const creator: PluginCreator<never> = () => {
9090
postcssPlugin: 'postcss-attribute-case-insensitive',
9191
Rule(rule) {
9292
if (rule.selector.includes('i]')) {
93-
rule.selector = selectorParser(transform).processSync(rule.selector);
93+
const modifiedSelector = selectorParser(transform).processSync(rule.selector);
94+
if (modifiedSelector === rule.selector) {
95+
return;
96+
}
97+
98+
rule.replaceWith(rule.clone({ selector: modifiedSelector }));
9499
}
95100
},
96101
};

plugins/postcss-cascade-layers/.tape.mjs

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ postcssTape(plugin)({
1212
nested: {
1313
message: "supports nested layer usage",
1414
},
15+
'nested-case-insensitive': {
16+
message: "supports layer and other keywords written in any case",
17+
},
1518
'nested-complex': {
1619
message: "supports nested layer usage",
1720
},

plugins/postcss-cascade-layers/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changes to PostCSS Cascade Layers
22

3+
### Unreleased
4+
5+
- Fix case insensitive `@layer` matching (`@LaYeR`).
6+
37
### 1.0.4 (June 23, 2022)
48

59
- Fix selector order with any pseudo element. This plugin will no longer re-order selectors.

plugins/postcss-cascade-layers/src/clean-blocks.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { CONDITIONAL_ATRULES } from './constants';
33

44
export function removeEmptyDescendantBlocks(block: Container) {
55
block.walk((node) => {
6-
if (node.type === 'rule' || (node.type === 'atrule' && ['layer', ...CONDITIONAL_ATRULES].includes(node.name))) {
6+
if (node.type === 'rule' || (node.type === 'atrule' && ['layer', ...CONDITIONAL_ATRULES].includes(node.name.toLowerCase()))) {
77
if (!node.nodes || !node.nodes.length) {
88
node.remove();
99
}

plugins/postcss-cascade-layers/src/desugar-and-parse-layer-names.ts

+11-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ export function desugarAndParseLayerNames(root: Container, model: Model) {
1010
// - parse layer names
1111
// - rename anon layers
1212
// - handle empty layers
13-
root.walkAtRules('layer', (layerRule) => {
13+
root.walkAtRules((layerRule) => {
14+
if (layerRule.name.toLowerCase() !== 'layer') {
15+
return;
16+
}
17+
1418
if (layerRule.params) {
1519
const layerNameList: Array<string> = [];
1620
let isInvalidLayerName = false;
@@ -86,7 +90,7 @@ export function desugarAndParseLayerNames(root: Container, model: Model) {
8690
layerRule.params = model.createAnonymousLayerName();
8791
}
8892

89-
const hasNestedLayers = someAtRuleInTree(layerRule, (node) => node.name === 'layer');
93+
const hasNestedLayers = someAtRuleInTree(layerRule, (node) => node.name.toLowerCase() === 'layer');
9094
const hasUnlayeredStyles = someInTree(layerRule, (node) => {
9195
if (node.type !== 'rule') {
9296
return;
@@ -104,7 +108,11 @@ export function desugarAndParseLayerNames(root: Container, model: Model) {
104108
});
105109

106110
// only keep unlayered styles for the implicit layer.
107-
implicitLayer.walkAtRules('layer', (node) => {
111+
implicitLayer.walkAtRules((node) => {
112+
if (node.name.toLowerCase() !== 'layer') {
113+
return;
114+
}
115+
108116
node.remove();
109117
});
110118

plugins/postcss-cascade-layers/src/desugar-nested-layers.ts

+7-3
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,21 @@ import { someAtRuleInTree } from './some-in-tree';
66
export function desugarNestedLayers(root: Container<ChildNode>, model: Model) {
77
while (someAtRuleInTree(root, (node) => {
88
return node.nodes && someAtRuleInTree(node, (nested) => {
9-
return nested.name === 'layer';
9+
return nested.name.toLowerCase() === 'layer';
1010
});
1111
})) {
1212
let foundUnexpectedLayerNesting = false;
1313

14-
root.walkAtRules('layer', (layerRule) => {
14+
root.walkAtRules((layerRule) => {
15+
if (layerRule.name.toLowerCase() !== 'layer') {
16+
return;
17+
}
18+
1519
if (layerRule.parent === root) {
1620
return;
1721
}
1822

19-
if (layerRule.parent.type === 'atrule' && (layerRule.parent as AtRule).name === 'layer') {
23+
if (layerRule.parent.type === 'atrule' && (layerRule.parent as AtRule).name.toLowerCase() === 'layer') {
2024
const parent = layerRule.parent as AtRule;
2125

2226
// Concatenate the current layer params with those of the parent. Store the result in the data model.

plugins/postcss-cascade-layers/src/get-conditional-atrule-ancestor.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export function getConditionalAtRuleAncestor(layerRule: AtRule): AtRule | null {
1010
continue;
1111
}
1212

13-
if (CONDITIONAL_ATRULES.includes((parent as AtRule).name)) {
13+
if (CONDITIONAL_ATRULES.includes((parent as AtRule).name.toLowerCase())) {
1414
return parent as AtRule;
1515
}
1616

plugins/postcss-cascade-layers/src/get-layer-atrule-ancestor.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export function getLayerAtRuleAncestor(node: Node): AtRule | null {
99
continue;
1010
}
1111

12-
if ((parent as AtRule).name === 'layer') {
12+
if ((parent as AtRule).name.toLowerCase() === 'layer') {
1313
return parent as AtRule;
1414
}
1515

plugins/postcss-cascade-layers/src/index.ts

+15-7
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,19 @@ const creator: PluginCreator<pluginOptions> = (opts?: pluginOptions) => {
2727
// Warnings
2828
if (options.onRevertLayerKeyword) {
2929
root.walkDecls((decl) => {
30-
if (decl.value === 'revert-layer') {
30+
if (decl.value.toLowerCase() === 'revert-layer') {
3131
decl.warn(result, 'handling "revert-layer" is unsupported by this plugin and will cause style differences between browser versions.');
3232
}
3333
});
3434
}
3535

3636
if (options.onImportLayerRule) {
37-
root.walkAtRules('import', (atRule) => {
38-
if (atRule.params.includes('layer')) {
37+
root.walkAtRules((atRule) => {
38+
if (atRule.name.toLowerCase() !== 'import') {
39+
return;
40+
}
41+
42+
if (atRule.params.toLowerCase().includes('layer')) {
3943
atRule.warn(result, 'To use @import with layers, the postcss-import plugin is also required. This plugin alone will not support using the @import at-rule.');
4044
}
4145
},
@@ -73,7 +77,7 @@ const creator: PluginCreator<pluginOptions> = (opts?: pluginOptions) => {
7377
// transform unlayered styles - need highest specificity (layerCount)
7478
root.walkRules((rule) => {
7579
// Skip any at rules that do not contain regular declarations (@keyframes)
76-
if (rule.parent && rule.parent.type === 'atrule' && ATRULES_WITH_NON_SELECTOR_BLOCK_LISTS.includes((rule.parent as AtRule).name)) {
80+
if (rule.parent && rule.parent.type === 'atrule' && ATRULES_WITH_NON_SELECTOR_BLOCK_LISTS.includes((rule.parent as AtRule).name.toLowerCase())) {
7781
return;
7882
}
7983

@@ -107,7 +111,7 @@ const creator: PluginCreator<pluginOptions> = (opts?: pluginOptions) => {
107111
// - give selectors the specificity they need based on layerPriority state
108112
root.walkRules((rule) => {
109113
// Skip any at rules that do not contain regular declarations (@keyframes)
110-
if (rule.parent && rule.parent.type === 'atrule' && ATRULES_WITH_NON_SELECTOR_BLOCK_LISTS.includes((rule.parent as AtRule).name)) {
114+
if (rule.parent && rule.parent.type === 'atrule' && ATRULES_WITH_NON_SELECTOR_BLOCK_LISTS.includes((rule.parent as AtRule).name.toLowerCase())) {
111115
return;
112116
}
113117

@@ -131,8 +135,12 @@ const creator: PluginCreator<pluginOptions> = (opts?: pluginOptions) => {
131135

132136
// Remove all @layer at-rules
133137
// Contained styles are inserted before
134-
while (someAtRuleInTree(root, (node) => node.name === 'layer')) {
135-
root.walkAtRules('layer', (atRule) => {
138+
while (someAtRuleInTree(root, (node) => node.name.toLowerCase() === 'layer')) {
139+
root.walkAtRules((atRule) => {
140+
if (atRule.name.toLowerCase() !== 'layer') {
141+
return;
142+
}
143+
136144
atRule.replaceWith(atRule.nodes);
137145
});
138146
}

plugins/postcss-cascade-layers/src/model.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export class Model {
7979
continue;
8080
}
8181

82-
if ((parent as AtRule).name === 'layer') {
82+
if ((parent as AtRule).name.toLowerCase() === 'layer') {
8383
params.push(...this.layerParamsParsed.get((parent as AtRule).params));
8484
}
8585

plugins/postcss-cascade-layers/src/record-layer-order.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ import { pluginOptions } from './options';
66

77
export function recordLayerOrder(root: Container, model: Model, { result, options }: { result: Result, options: pluginOptions }) {
88
// record layer order
9-
root.walkAtRules('layer', (layerRule) => {
9+
root.walkAtRules((layerRule) => {
10+
if (layerRule.name.toLowerCase() !== 'layer') {
11+
return;
12+
}
13+
1014
const currentLayerNameParts = model.getLayerParams(layerRule);
1115
const fullLayerName = currentLayerNameParts.join('.');
1216
if (model.layerOrder.has(fullLayerName)) {

0 commit comments

Comments
 (0)