@@ -42,7 +42,11 @@ module.exports = function (input) {
42
42
} else if ( code === comma || code === colon || code === slash && value . charCodeAt ( next + 1 ) !== star ) {
43
43
before = token ;
44
44
} else {
45
- tokens . push ( { type : 'space' , sourceIndex : pos , value : token } ) ;
45
+ tokens . push ( {
46
+ type : 'space' ,
47
+ sourceIndex : pos ,
48
+ value : token
49
+ } ) ;
46
50
}
47
51
48
52
pos = next ;
@@ -51,7 +55,11 @@ module.exports = function (input) {
51
55
} else if ( code === singleQuote || code === doubleQuote ) {
52
56
next = pos ;
53
57
quote = code === singleQuote ? '\'' : '"' ;
54
- token = { type : 'string' , sourceIndex : pos , quote : quote } ;
58
+ token = {
59
+ type : 'string' ,
60
+ sourceIndex : pos ,
61
+ quote : quote
62
+ } ;
55
63
do {
56
64
escape = false ;
57
65
next = value . indexOf ( quote , next + 1 ) ;
@@ -75,7 +83,10 @@ module.exports = function (input) {
75
83
76
84
//Comments
77
85
} else if ( code === slash && value . charCodeAt ( pos + 1 ) === star ) {
78
- token = { type : 'comment' , sourceIndex : pos } ;
86
+ token = {
87
+ type : 'comment' ,
88
+ sourceIndex : pos
89
+ } ;
79
90
80
91
next = value . indexOf ( '*/' , pos ) ;
81
92
if ( next === - 1 ) {
@@ -93,7 +104,13 @@ module.exports = function (input) {
93
104
} else if ( code === slash || code === comma || code === colon ) {
94
105
token = value [ pos ] ;
95
106
96
- tokens . push ( { type : 'div' , sourceIndex : pos - before . length , value : token , before : before , after : '' } ) ;
107
+ tokens . push ( {
108
+ type : 'div' ,
109
+ sourceIndex : pos - before . length ,
110
+ value : token ,
111
+ before : before ,
112
+ after : ''
113
+ } ) ;
97
114
before = '' ;
98
115
99
116
pos += 1 ;
@@ -107,7 +124,12 @@ module.exports = function (input) {
107
124
next += 1 ;
108
125
code = value . charCodeAt ( next ) ;
109
126
} while ( code <= 32 ) ;
110
- token = { type : 'function' , sourceIndex : pos - name . length , value : name , before : value . slice ( pos + 1 , next ) } ;
127
+ token = {
128
+ type : 'function' ,
129
+ sourceIndex : pos - name . length ,
130
+ value : name ,
131
+ before : value . slice ( pos + 1 , next )
132
+ } ;
111
133
pos = next ;
112
134
113
135
if ( name === 'url' && code !== singleQuote && code !== doubleQuote ) {
@@ -134,13 +156,21 @@ module.exports = function (input) {
134
156
code = value . charCodeAt ( whitespacePos ) ;
135
157
} while ( code <= 32 ) ;
136
158
if ( pos !== whitespacePos + 1 ) {
137
- token . nodes = [ { type : 'word' , sourceIndex : pos , value : value . slice ( pos , whitespacePos + 1 ) } ] ;
159
+ token . nodes = [ {
160
+ type : 'word' ,
161
+ sourceIndex : pos ,
162
+ value : value . slice ( pos , whitespacePos + 1 )
163
+ } ] ;
138
164
} else {
139
165
token . nodes = [ ] ;
140
166
}
141
167
if ( token . unclosed && whitespacePos + 1 !== next ) {
142
168
token . after = '' ;
143
- token . nodes . push ( { type : 'space' , sourceIndex : whitespacePos + 1 , value : value . slice ( whitespacePos + 1 , next ) } ) ;
169
+ token . nodes . push ( {
170
+ type : 'space' ,
171
+ sourceIndex : whitespacePos + 1 ,
172
+ value : value . slice ( whitespacePos + 1 , next )
173
+ } ) ;
144
174
} else {
145
175
token . after = value . slice ( whitespacePos + 1 , next ) ;
146
176
}
@@ -180,16 +210,24 @@ module.exports = function (input) {
180
210
code = value . charCodeAt ( next ) ;
181
211
} while ( next < max && ! (
182
212
code <= 32 ||
183
- code === singleQuote || code === doubleQuote ||
184
- code === slash && value . charCodeAt ( next + 1 ) !== star || code === comma || code === colon ||
185
- code === openParentheses || code === closeParentheses && balanced
213
+ code === singleQuote ||
214
+ code === doubleQuote ||
215
+ code === comma ||
216
+ code === colon ||
217
+ code === slash && value . charCodeAt ( next + 1 ) !== star ||
218
+ code === openParentheses ||
219
+ code === closeParentheses && balanced
186
220
) ) ;
187
221
token = value . slice ( pos , next ) ;
188
222
189
223
if ( openParentheses === code ) {
190
224
name = token ;
191
225
} else {
192
- tokens . push ( { type : 'word' , sourceIndex : pos , value : token } ) ;
226
+ tokens . push ( {
227
+ type : 'word' ,
228
+ sourceIndex : pos ,
229
+ value : token
230
+ } ) ;
193
231
}
194
232
195
233
pos = next ;
0 commit comments