File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- let valueParser = require ( 'postcss-value-parser' ) ;
1+ let valueParser = require ( 'postcss-value-parser' )
22
33const PREFERS_COLOR_ONLY = / ^ \( \s * p r e f e r s - c o l o r - s c h e m e \s * : \s * ( d a r k | l i g h t ) \s * \) $ /
44const PREFERS_COLOR = / \( \s * p r e f e r s - c o l o r - s c h e m e \s * : \s * ( d a r k | l i g h t ) \s * \) / g
@@ -43,10 +43,14 @@ function extractLightDark(isDark, declarationValue) {
4343function mutateLightDarkRec ( isDark , parsed ) {
4444 let wasMutated = false
4545 parsed . walk ( node => {
46- if ( wasMutated || node . type !== 'function' || node . value !== 'light-dark' ) return
47-
46+ if ( wasMutated || node . type !== 'function' || node . value !== 'light-dark' ) {
47+ return
48+ }
49+
4850 let light = node . nodes [ 0 ]
49- let dark = node . nodes . find ( ( x , i ) => i > 0 && ( x . type === 'word' || x . type === 'function' ) )
51+ let dark = node . nodes . find ( ( child , index ) => {
52+ return index > 0 && ( child . type === 'word' || child . type === 'function' )
53+ } )
5054 Object . assign ( node , isDark ? dark : light )
5155 mutateLightDarkRec ( isDark , parsed )
5256 wasMutated = true
@@ -108,8 +112,13 @@ module.exports = (opts = {}) => {
108112
109113 return {
110114 AtRuleExit : {
111- media : atrule => {
112- if ( ! atrule . params . includes ( 'dark' ) && ! atrule . params . includes ( 'light' ) ) return
115+ media ( atrule ) {
116+ if (
117+ ! atrule . params . includes ( 'dark' ) &&
118+ ! atrule . params . includes ( 'light' )
119+ ) {
120+ return
121+ }
113122
114123 let params = atrule . params
115124 let fixedSelector = params . includes ( 'dark' ) ? dark : light
You can’t perform that action at this time.
0 commit comments