@@ -27,15 +27,19 @@ const creator: PluginCreator<pluginOptions> = (opts?: pluginOptions) => {
27
27
// Warnings
28
28
if ( options . onRevertLayerKeyword ) {
29
29
root . walkDecls ( ( decl ) => {
30
- if ( decl . value === 'revert-layer' ) {
30
+ if ( decl . value . toLowerCase ( ) === 'revert-layer' ) {
31
31
decl . warn ( result , 'handling "revert-layer" is unsupported by this plugin and will cause style differences between browser versions.' ) ;
32
32
}
33
33
} ) ;
34
34
}
35
35
36
36
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' ) ) {
39
43
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.' ) ;
40
44
}
41
45
} ,
@@ -73,7 +77,7 @@ const creator: PluginCreator<pluginOptions> = (opts?: pluginOptions) => {
73
77
// transform unlayered styles - need highest specificity (layerCount)
74
78
root . walkRules ( ( rule ) => {
75
79
// 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 ( ) ) ) {
77
81
return ;
78
82
}
79
83
@@ -107,7 +111,7 @@ const creator: PluginCreator<pluginOptions> = (opts?: pluginOptions) => {
107
111
// - give selectors the specificity they need based on layerPriority state
108
112
root . walkRules ( ( rule ) => {
109
113
// 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 ( ) ) ) {
111
115
return ;
112
116
}
113
117
@@ -131,8 +135,12 @@ const creator: PluginCreator<pluginOptions> = (opts?: pluginOptions) => {
131
135
132
136
// Remove all @layer at-rules
133
137
// 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
+
136
144
atRule . replaceWith ( atRule . nodes ) ;
137
145
} ) ;
138
146
}
0 commit comments