File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed
experimental/css-has-pseudo/src Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ const creator: PluginCreator<{ preserve?: boolean, specificityMatchingName?: str
16
16
return {
17
17
postcssPlugin : 'css-has-pseudo-experimental' ,
18
18
RuleExit : ( rule , { result } ) => {
19
- if ( ! rule . selector . includes ( ':has(' ) ) {
19
+ if ( ! rule . selector . includes ( ':has(' ) || isWithinSupportCheck ( rule ) ) {
20
20
return ;
21
21
}
22
22
@@ -102,6 +102,22 @@ creator.postcss = true;
102
102
103
103
export default creator ;
104
104
105
+ function isWithinSupportCheck ( rule ) {
106
+ let isSupportCheck = false ;
107
+ let ruleParent = rule . parent ;
108
+
109
+ while ( ! isSupportCheck && ruleParent ) {
110
+ if ( ruleParent . type === 'atrule' ) {
111
+
112
+ isSupportCheck = ruleParent . params . includes ( ':has(' ) && ruleParent . params . startsWith ( 'selector(' ) ;
113
+ }
114
+
115
+ ruleParent = ruleParent . parent ;
116
+ }
117
+
118
+ return isSupportCheck ;
119
+ }
120
+
105
121
function selectorSpecificity ( node ) {
106
122
let a = 0 ;
107
123
let b = 0 ;
You can’t perform that action at this time.
0 commit comments