@@ -7,7 +7,7 @@ var gatherVariableDependencies = require('./gather-variable-dependencies');
7
7
var findNodeAncestorWithSelector = require ( './find-node-ancestor-with-selector' ) ;
8
8
var cloneSpliceParentOntoNodeWhen = require ( './clone-splice-parent-onto-node-when' ) ;
9
9
10
- // regex to capture variable names
10
+ // Regexp to capture variable names
11
11
var RE_VAR_FUNC = ( / v a r \( \s * ( - - [ ^ , \s ) ] + ) / ) ;
12
12
13
13
function toString ( value ) {
@@ -35,12 +35,12 @@ var resolveValue = function(decl, map, /*optional*/ignorePseudoScope, /*internal
35
35
var warnings = [ ] ;
36
36
37
37
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
39
39
var variablesUsedInValue = [ ] ;
40
40
while ( ( matchingVarDecl = RE_VAR_FUNC_G . exec ( resultantValue ) ) ) {
41
41
variablesUsedInValue . push ( matchingVarDecl [ 1 ] ) ;
42
42
}
43
- // remove duplicates from array
43
+ // Remove duplicates from array
44
44
variablesUsedInValue = variablesUsedInValue . filter ( filterDistinct ) ;
45
45
46
46
//console.log(debugIndent, (_debugIsInternal ? '' : 'Try resolving'), generateScopeList(decl.parent, true), `ignorePseudoScope=${ignorePseudoScope}`, '------------------------');
@@ -55,10 +55,10 @@ var resolveValue = function(decl, map, /*optional*/ignorePseudoScope, /*internal
55
55
var matchingVarDeclMapItem = undefined ;
56
56
57
57
// 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
59
59
var variableFallbackSplitPieces = matchingVarDecl . body . split ( ',' ) ;
60
60
61
- // get variable name and fallback, filtering empty items
61
+ // Get variable name and fallback, filtering empty items
62
62
var variableName = variableFallbackSplitPieces [ 0 ] . trim ( ) ;
63
63
var fallback = variableFallbackSplitPieces . length > 1 ? variableFallbackSplitPieces . slice ( 1 ) . join ( ',' ) . trim ( ) : undefined ;
64
64
@@ -112,7 +112,7 @@ var resolveValue = function(decl, map, /*optional*/ignorePseudoScope, /*internal
112
112
warnings . push ( [ 'variable ' + variableName + ' is undefined and used without a fallback' , { node : decl } ] ) ;
113
113
}
114
114
115
- // replace original declaration
115
+ // Replace original declaration with found value
116
116
resultantValue = ( matchingVarDecl . pre || '' ) + replaceValue + ( matchingVarDecl . post || '' )
117
117
}
118
118
0 commit comments