@@ -7,7 +7,7 @@ var gatherVariableDependencies = require('./gather-variable-dependencies');
77var findNodeAncestorWithSelector = require ( './find-node-ancestor-with-selector' ) ;
88var cloneSpliceParentOntoNodeWhen = require ( './clone-splice-parent-onto-node-when' ) ;
99
10- // regex to capture variable names
10+ // Regexp to capture variable names
1111var RE_VAR_FUNC = ( / v a r \( \s * ( - - [ ^ , \s ) ] + ) / ) ;
1212
1313function toString ( value ) {
@@ -35,12 +35,12 @@ var resolveValue = function(decl, map, /*optional*/ignorePseudoScope, /*internal
3535 var warnings = [ ] ;
3636
3737
38- // match all variables first, to gather all available variables in decl.value
38+ // Match all variables first so we can later on if there are circular dependencies
3939 var variablesUsedInValue = [ ] ;
4040 while ( ( matchingVarDecl = RE_VAR_FUNC_G . exec ( resultantValue ) ) ) {
4141 variablesUsedInValue . push ( matchingVarDecl [ 1 ] ) ;
4242 }
43- // remove duplicates from array
43+ // Remove duplicates from array
4444 variablesUsedInValue = variablesUsedInValue . filter ( filterDistinct ) ;
4545
4646 //console.log(debugIndent, (_debugIsInternal ? '' : 'Try resolving'), generateScopeList(decl.parent, true), `ignorePseudoScope=${ignorePseudoScope}`, '------------------------');
@@ -55,10 +55,10 @@ var resolveValue = function(decl, map, /*optional*/ignorePseudoScope, /*internal
5555 var matchingVarDeclMapItem = undefined ;
5656
5757 // Split at the comma to find variable name and fallback value
58- // There may be other commas in the values so this isn't necessary just 2 pieces
58+ // There may be other commas in the values so this isn't necessarily just 2 pieces
5959 var variableFallbackSplitPieces = matchingVarDecl . body . split ( ',' ) ;
6060
61- // get variable name and fallback, filtering empty items
61+ // Get variable name and fallback, filtering empty items
6262 var variableName = variableFallbackSplitPieces [ 0 ] . trim ( ) ;
6363 var fallback = variableFallbackSplitPieces . length > 1 ? variableFallbackSplitPieces . slice ( 1 ) . join ( ',' ) . trim ( ) : undefined ;
6464
@@ -112,7 +112,7 @@ var resolveValue = function(decl, map, /*optional*/ignorePseudoScope, /*internal
112112 warnings . push ( [ 'variable ' + variableName + ' is undefined and used without a fallback' , { node : decl } ] ) ;
113113 }
114114
115- // replace original declaration
115+ // Replace original declaration with found value
116116 resultantValue = ( matchingVarDecl . pre || '' ) + replaceValue + ( matchingVarDecl . post || '' )
117117 }
118118
0 commit comments