1
- 'use strict;'
1
+ 'use strict;' ;
2
2
// CSS Parser
3
3
var css = require ( 'css' ) ;
4
4
// Convert words to camelCase
@@ -7,7 +7,7 @@ var camelCase = require('camelcase');
7
7
// To accomplish loading CSS to an Object, the process is:
8
8
// 1. Parse CSS stylesheet to AST
9
9
// 2. Flatten AST to Object of shape { [rule.selector]: rule.declarations }
10
- module . exports = function cssObjectLoader ( source ) {
10
+ module . exports = function cssObjectLoader ( source ) {
11
11
this . cacheable && this . cacheable ( ) ;
12
12
// Step 1.
13
13
var parsedStylesheet = getParsedStylesheet ( source ) ;
@@ -17,12 +17,12 @@ module.exports = function cssObjectLoader(source) {
17
17
} ;
18
18
19
19
// Parse the contents of the CSS file and get the resulting AST
20
- function getParsedStylesheet ( source ) {
20
+ function getParsedStylesheet ( source ) {
21
21
return css . parse ( source ) . stylesheet ;
22
22
}
23
23
24
24
// Return `true` for an AST node with { type: 'rule' } and valid selectors
25
- function isValidRule ( rule ) {
25
+ function isValidRule ( rule ) {
26
26
return ! ! ( rule . type === 'rule' && rule . selectors && rule . selectors . length ) ;
27
27
}
28
28
// Return `true` for an AST node with { type: 'declaration' } and any property
@@ -31,7 +31,7 @@ function isValidDeclaration (declaration) {
31
31
}
32
32
33
33
// Reduce a declaration node from the AST to a style object
34
- function reduceDeclarationsToStyleObject ( styleObj , declaration ) {
34
+ function reduceDeclarationsToStyleObject ( styleObj , declaration ) {
35
35
if ( ! isValidDeclaration ( declaration ) ) {
36
36
return styleObj ;
37
37
}
@@ -42,15 +42,15 @@ function reduceDeclarationsToStyleObject(styleObj, declaration) {
42
42
}
43
43
44
44
// Reduce a rule to a collection of selectors
45
- function reduceRulesToSelectors ( selectors , rule ) {
45
+ function reduceRulesToSelectors ( selectors , rule ) {
46
46
if ( ! isValidRule ( rule ) ) {
47
47
return selectors ;
48
48
}
49
- var styleObject = rule . declarations . reduce ( reduceDeclarationsToStyleObject , { } )
49
+ var styleObject = rule . declarations . reduce ( reduceDeclarationsToStyleObject , { } ) ;
50
50
rule . selectors . forEach ( ( selector ) => {
51
51
selectors [ selector ] = Object . assign ( { } ,
52
52
selectors [ selector ] ,
53
- styleObject
53
+ styleObject
54
54
) ;
55
55
} ) ;
56
56
return selectors ;
0 commit comments