File tree Expand file tree Collapse file tree 5 files changed +37
-2
lines changed Expand file tree Collapse file tree 5 files changed +37
-2
lines changed Original file line number Diff line number Diff line change 1
1
# Changes to PostCSS Editor Styles
2
2
3
+ ### 0.5.0 (March 7, 2024)
4
+
5
+ - Allow using ` :where() ` pseudo class in options to account for every ` :where(*) ` selectors.
6
+
3
7
### 0.4.0 (March 7, 2024)
4
8
5
9
- Fixed a bug where some tags weren't getting scoped ([ #5 ] ( https://github.com/m-e-h/postcss-editor-styles/pull/5 ) ) thanks to @animeshk874
Original file line number Diff line number Diff line change @@ -39,13 +39,33 @@ module.exports = (options = {}) => {
39
39
40
40
const opts = { ...defaults , ...options } ;
41
41
42
+ // Detect if there is a :where() pseudo class in the selectors.
43
+ const hasWherePseudo = ( optionsVal , selectors ) => {
44
+ let optionHasWhere = false ;
45
+
46
+ if ( typeof optionsVal === 'string' ) {
47
+ optionHasWhere = ':where()' === optionsVal ;
48
+ } else if ( Array . isArray ( optionsVal ) ) {
49
+ optionHasWhere = optionsVal . find ( ( el ) => el === ':where()' ) ;
50
+ }
51
+
52
+ if ( ! optionHasWhere ) {
53
+ return false ;
54
+ }
55
+
56
+ return selectors . find ( ( el ) => el . startsWith ( ':where(' ) ) ;
57
+ }
58
+
42
59
const firstOrLastSelector = ( optsArray , selectorArray ) => {
43
60
let firstSelector = selectorArray [ 0 ] ;
44
61
let lastSelector = selectorArray [ selectorArray . length - 1 ] ;
62
+ const whereMatch = hasWherePseudo ( optsArray , [ firstSelector , lastSelector ] ) ;
45
63
46
64
var selectorIn = [ ] ;
47
65
48
- if ( - 1 !== optsArray . indexOf ( firstSelector ) ) {
66
+ if ( whereMatch ) {
67
+ selectorIn . push ( whereMatch ) ;
68
+ } else if ( - 1 !== optsArray . indexOf ( firstSelector ) ) {
49
69
selectorIn . push ( firstSelector ) ;
50
70
} else if ( - 1 !== optsArray . indexOf ( lastSelector ) ) {
51
71
selectorIn . push ( lastSelector ) ;
Original file line number Diff line number Diff line change @@ -3,7 +3,10 @@ const plugin = require('../index.js');
3
3
4
4
postcssTape ( plugin ) ( {
5
5
basic : {
6
- message : 'supports basic usage'
6
+ message : 'supports basic usage' ,
7
+ options : {
8
+ ignore : [ ':root' , ':where()' ] ,
9
+ }
7
10
} ,
8
11
remove : {
9
12
message : 'supports remove usage'
Original file line number Diff line number Diff line change
1
+ : where (.wp-site-blocks ) li {
2
+ border-bottom : 1px solid # e1e4e8 ;
3
+ }
4
+
1
5
: root {
2
6
--color-text : # 24292e ;
3
7
}
Original file line number Diff line number Diff line change
1
+ : where (.wp-site-blocks ) li {
2
+ border-bottom : 1px solid # e1e4e8 ;
3
+ }
4
+
1
5
: root {
2
6
--color-text : # 24292e ;
3
7
}
You can’t perform that action at this time.
0 commit comments