@@ -49,12 +49,10 @@ var defaults = {
49
49
preserveInjectedVariables : true
50
50
} ;
51
51
52
- module . exports = postcss . plugin ( 'postcss-css-variables' , function ( options ) {
52
+ const cssvariables = postcss . plugin ( 'postcss-css-variables' , function ( options ) {
53
53
54
54
var opts = Object . assign ( { } , defaults , options ) ;
55
55
56
- // Work with opts here
57
-
58
56
return function ( css , result ) {
59
57
// Map of variable names to a list of declarations
60
58
let map = { } ;
@@ -140,6 +138,7 @@ module.exports = postcss.plugin('postcss-css-variables', function(options) {
140
138
return ;
141
139
}
142
140
141
+ // TODO: Is there a way to walk the decls backwards so we can get the @media queries in the correct order
143
142
const newUsageDecl = expandVarUsageFromVarDefinition ( variableEntry , variableDecl , usageDecl ) ;
144
143
// Keep track of the cloned decls we should skip over
145
144
usageDeclsToSkip . push ( newUsageDecl ) ;
@@ -160,7 +159,7 @@ module.exports = postcss.plugin('postcss-css-variables', function(options) {
160
159
161
160
// Clean up the rule that declared them if it doesn't have anything left after we potentially remove the variable decl
162
161
let currentNodeToCheckEmpty = variableDeclParentRule ;
163
- while ( currentNodeToCheckEmpty . nodes . length === 0 ) {
162
+ while ( currentNodeToCheckEmpty && currentNodeToCheckEmpty . nodes . length === 0 ) {
164
163
const nodeToRemove = currentNodeToCheckEmpty ;
165
164
currentNodeToCheckEmpty = nodeToRemove . parent ;
166
165
nodeToRemove . remove ( ) ;
@@ -255,3 +254,6 @@ module.exports = postcss.plugin('postcss-css-variables', function(options) {
255
254
256
255
} ;
257
256
} ) ;
257
+
258
+
259
+ module . exports = cssvariables ;
0 commit comments