File tree Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change
1
+ // This is a very temporary fix to split :has() selectors
2
+ // into their own rules for `optimizeUniversalDefaults`
3
+ module . exports = function ( ) {
4
+ return {
5
+ postcssPlugin : 'has-fixup' ,
6
+ RuleExit ( rule , { Rule } ) {
7
+ if ( rule . selectors . length < 2 ) {
8
+ return
9
+ }
10
+
11
+ if ( ! rule . selectors . some ( s => s . includes ( ':has' ) ) ) {
12
+ return
13
+ }
14
+
15
+ let withHas = [ ]
16
+ let withoutHas = [ ]
17
+
18
+ // Find every selector with the :has() pseudo-class
19
+ for ( let sel of rule . selectors ) {
20
+ if ( sel . includes ( ':has' ) ) {
21
+ withHas . push ( sel )
22
+ } else {
23
+ withoutHas . push ( sel )
24
+ }
25
+ }
26
+
27
+ // Remove the :has() selectors from the original rule
28
+ rule . selectors = withoutHas
29
+
30
+ // Add the :has() selectors to a new rule
31
+ const newRule = new Rule ( {
32
+ selectors : withHas ,
33
+ nodes : rule . clone ( ) . nodes ,
34
+ } )
35
+
36
+ rule . parent . insertAfter ( rule , newRule )
37
+ }
38
+ }
39
+ } ;
40
+
41
+ module . exports . postcss = true ;
Original file line number Diff line number Diff line change @@ -5,5 +5,6 @@ module.exports = {
5
5
'tailwindcss' ,
6
6
'postcss-focus-visible' ,
7
7
'autoprefixer' ,
8
+ require . resolve ( './has-fixup.js' ) ,
8
9
] ,
9
10
}
You can’t perform that action at this time.
0 commit comments