@@ -35,47 +35,47 @@ var tests = [{
35
35
message : 'should process unopened parentheses as word' ,
36
36
fixture : '() )wo)rd)' ,
37
37
expected : [
38
- { type : 'function' , value : '' , before : '' , after : '' , nodes : [ ] } ,
38
+ { type : 'function' , sourceIndex : 0 , value : '' , before : '' , after : '' , nodes : [ ] } ,
39
39
{ type : 'space' , sourceIndex : 2 , value : ' ' } ,
40
40
{ type : 'word' , sourceIndex : 3 , value : ')wo)rd)' }
41
41
]
42
42
} , {
43
43
message : 'should add before prop' ,
44
44
fixture : '( )' ,
45
45
expected : [
46
- { type : 'function' , value : '' , before : ' ' , after : '' , nodes : [ ] }
46
+ { type : 'function' , sourceIndex : 0 , value : '' , before : ' ' , after : '' , nodes : [ ] }
47
47
]
48
48
} , {
49
49
message : 'should add before and after prop' ,
50
50
fixture : '( | )' ,
51
51
expected : [
52
- { type : 'function' , value : '' , before : ' ' , after : ' ' , nodes : [
52
+ { type : 'function' , sourceIndex : 0 , value : '' , before : ' ' , after : ' ' , nodes : [
53
53
{ type : 'word' , sourceIndex : 2 , value : '|' }
54
54
] }
55
55
]
56
56
} , {
57
57
message : 'should add value prop' ,
58
58
fixture : 'name()' ,
59
59
expected : [
60
- { type : 'function' , value : 'name' , before : '' , after : '' , nodes : [ ] }
60
+ { type : 'function' , sourceIndex : 0 , value : 'name' , before : '' , after : '' , nodes : [ ] }
61
61
]
62
62
} , {
63
63
message : 'should process nested functions' ,
64
64
fixture : '((()))' ,
65
65
expected : [
66
- { type : 'function' , value : '' , before : '' , after : '' , nodes : [
67
- { type : 'function' , value : '' , before : '' , after : '' , nodes : [
68
- { type : 'function' , value : '' , before : '' , after : '' , nodes : [ ] }
66
+ { type : 'function' , sourceIndex : 0 , value : '' , before : '' , after : '' , nodes : [
67
+ { type : 'function' , sourceIndex : 1 , value : '' , before : '' , after : '' , nodes : [
68
+ { type : 'function' , sourceIndex : 2 , value : '' , before : '' , after : '' , nodes : [ ] }
69
69
] }
70
70
] }
71
71
]
72
72
} , {
73
73
message : 'should process advanced nested functions' ,
74
74
fixture : '( calc(( ) ))word' ,
75
75
expected : [
76
- { type : 'function' , value : '' , before : ' ' , after : '' , nodes : [
77
- { type : 'function' , value : 'calc' , before : '' , after : ' ' , nodes : [
78
- { type : 'function' , value : '' , before : ' ' , after : '' , nodes : [ ] }
76
+ { type : 'function' , sourceIndex : 0 , value : '' , before : ' ' , after : '' , nodes : [
77
+ { type : 'function' , sourceIndex : 2 , value : 'calc' , before : '' , after : ' ' , nodes : [
78
+ { type : 'function' , sourceIndex : 7 , value : '' , before : ' ' , after : '' , nodes : [ ] }
79
79
] }
80
80
] } ,
81
81
{ type : 'word' , sourceIndex : 13 , value : 'word' }
@@ -108,7 +108,7 @@ var tests = [{
108
108
message : 'should process divider in function' ,
109
109
fixture : '( , )' ,
110
110
expected : [
111
- { type : 'function' , value : '' , before : ' ' , after : ' ' , nodes : [
111
+ { type : 'function' , sourceIndex : 0 , value : '' , before : ' ' , after : ' ' , nodes : [
112
112
{ type : 'div' , value : ',' , before : '' , after : '' }
113
113
] }
114
114
]
@@ -221,7 +221,7 @@ var tests = [{
221
221
message : 'should correctly proceess color value' ,
222
222
fixture : 'rgba( 29, 439 , 29 )' ,
223
223
expected : [
224
- { type : 'function' , value : 'rgba' , before : ' ' , after : ' ' , nodes : [
224
+ { type : 'function' , sourceIndex : 0 , value : 'rgba' , before : ' ' , after : ' ' , nodes : [
225
225
{ type : 'word' , sourceIndex : 6 , value : '29' } ,
226
226
{ type : 'div' , value : ',' , before : '' , after : ' ' } ,
227
227
{ type : 'word' , sourceIndex : 10 , value : '439' } ,
@@ -233,15 +233,15 @@ var tests = [{
233
233
message : 'should correctly process url function' ,
234
234
fixture : 'url( /gfx/img/bg.jpg )' ,
235
235
expected : [
236
- { type : 'function' , value : 'url' , before : ' ' , after : ' ' , nodes : [
236
+ { type : 'function' , sourceIndex : 0 , value : 'url' , before : ' ' , after : ' ' , nodes : [
237
237
{ type : 'word' , sourceIndex : 5 , value : '/gfx/img/bg.jpg' }
238
238
] }
239
239
]
240
240
} , {
241
241
message : 'should add unclosed: true prop for url function' ,
242
242
fixture : 'url( /gfx/img/bg.jpg ' ,
243
243
expected : [
244
- { type : 'function' , value : 'url' , before : ' ' , after : '' , unclosed : true , nodes : [
244
+ { type : 'function' , sourceIndex : 0 , value : 'url' , before : ' ' , after : '' , unclosed : true , nodes : [
245
245
{ type : 'word' , sourceIndex : 5 , value : '/gfx/img/bg.jpg' } ,
246
246
{ type : 'space' , sourceIndex : 20 , value : ' ' }
247
247
] }
@@ -250,7 +250,7 @@ var tests = [{
250
250
message : 'should correctly process url function with quoted first argument' ,
251
251
fixture : 'url( "/gfx/img/bg.jpg" hello )' ,
252
252
expected : [
253
- { type : 'function' , value : 'url' , before : ' ' , after : ' ' , nodes : [
253
+ { type : 'function' , sourceIndex : 0 , value : 'url' , before : ' ' , after : ' ' , nodes : [
254
254
{ type : 'string' , sourceIndex : 5 , quote : '"' , value : '/gfx/img/bg.jpg' } ,
255
255
{ type : 'space' , sourceIndex : 22 , value : ' ' } ,
256
256
{ type : 'word' , sourceIndex : 23 , value : 'hello' }
@@ -260,9 +260,9 @@ var tests = [{
260
260
message : 'should correctly process nested calc functions' ,
261
261
fixture : 'calc(((768px - 100vw) / 2) - 15px)' ,
262
262
expected : [
263
- { type : 'function' , value : 'calc' , before : '' , after : '' , nodes : [
264
- { type : 'function' , value : '' , before : '' , after : '' , nodes : [
265
- { type : 'function' , value : '' , before : '' , after : '' , nodes : [
263
+ { type : 'function' , sourceIndex : 0 , value : 'calc' , before : '' , after : '' , nodes : [
264
+ { type : 'function' , sourceIndex : 5 , value : '' , before : '' , after : '' , nodes : [
265
+ { type : 'function' , sourceIndex : 6 , value : '' , before : '' , after : '' , nodes : [
266
266
{ type : 'word' , sourceIndex : 7 , value : '768px' } ,
267
267
{ type : 'space' , sourceIndex : 12 , value : ' ' } ,
268
268
{ type : 'word' , sourceIndex : 13 , value : '-' } ,
@@ -282,15 +282,15 @@ var tests = [{
282
282
message : 'should process colons with params' ,
283
283
fixture : '(min-width: 700px) and (orientation: \\$landscape)' ,
284
284
expected : [
285
- { type : 'function' , value : '' , before : '' , after : '' , nodes : [
285
+ { type : 'function' , sourceIndex : 0 , value : '' , before : '' , after : '' , nodes : [
286
286
{ type : 'word' , sourceIndex : 1 , value : 'min-width' } ,
287
287
{ type : 'div' , value : ':' , before : '' , after : ' ' } ,
288
288
{ type : 'word' , sourceIndex : 12 , value : '700px' }
289
289
] } ,
290
290
{ type : 'space' , sourceIndex : 18 , value : ' ' } ,
291
291
{ type : 'word' , sourceIndex : 19 , value : 'and' } ,
292
292
{ type : 'space' , sourceIndex : 22 , value : ' ' } ,
293
- { type : 'function' , value : '' , before : '' , after : '' , nodes : [
293
+ { type : 'function' , sourceIndex : 23 , value : '' , before : '' , after : '' , nodes : [
294
294
{ type : 'word' , sourceIndex : 24 , value : 'orientation' } ,
295
295
{ type : 'div' , value : ':' , before : '' , after : ' ' } ,
296
296
{ type : 'word' , sourceIndex : 37 , value : '\\$landscape' }
@@ -300,26 +300,26 @@ var tests = [{
300
300
message : 'should escape parentheses with backslash' ,
301
301
fixture : 'url( http://website.com/assets\\)_test )' ,
302
302
expected : [
303
- { type : 'function' , value : 'url' , before : ' ' , after : ' ' , nodes : [
303
+ { type : 'function' , sourceIndex : 0 , value : 'url' , before : ' ' , after : ' ' , nodes : [
304
304
{ type : 'word' , sourceIndex : 5 , value : 'http://website.com/assets\\)_test' }
305
305
] }
306
306
]
307
307
} , {
308
308
message : 'should parse parentheses correctly' ,
309
309
fixture : 'fn1(fn2(255), fn3(.2)), fn4(fn5(255,.2), fn6)' ,
310
310
expected : [
311
- { type : 'function' , value : 'fn1' , before : '' , after : '' , nodes : [
312
- { type : 'function' , value : 'fn2' , before : '' , after : '' , nodes : [
311
+ { type : 'function' , sourceIndex : 0 , value : 'fn1' , before : '' , after : '' , nodes : [
312
+ { type : 'function' , sourceIndex : 4 , value : 'fn2' , before : '' , after : '' , nodes : [
313
313
{ type : 'word' , sourceIndex : 8 , value : '255' }
314
314
] } ,
315
315
{ type : 'div' , value : ',' , before : '' , after : ' ' } ,
316
- { type : 'function' , value : 'fn3' , before : '' , after : '' , nodes : [
316
+ { type : 'function' , sourceIndex : 14 , value : 'fn3' , before : '' , after : '' , nodes : [
317
317
{ type : 'word' , sourceIndex : 18 , value : '.2' }
318
318
] } ,
319
319
] } ,
320
320
{ type : 'div' , value : ',' , before : '' , after : ' ' } ,
321
- { type : 'function' , value : 'fn4' , before : '' , after : '' , nodes : [
322
- { type : 'function' , value : 'fn5' , before : '' , after : '' , nodes : [
321
+ { type : 'function' , sourceIndex : 24 , value : 'fn4' , before : '' , after : '' , nodes : [
322
+ { type : 'function' , sourceIndex : 28 , value : 'fn5' , before : '' , after : '' , nodes : [
323
323
{ type : 'word' , sourceIndex : 32 , value : '255' } ,
324
324
{ type : 'div' , value : ',' , before : '' , after : '' } ,
325
325
{ type : 'word' , sourceIndex : 36 , value : '.2' }
@@ -332,7 +332,7 @@ var tests = [{
332
332
message : 'shouldn\'t throw an error on unclosed function' ,
333
333
fixture : '(0 32 word ' ,
334
334
expected : [
335
- { type : 'function' , value : '' , before : '' , after : '' , unclosed : true , nodes : [
335
+ { type : 'function' , sourceIndex : 0 , value : '' , before : '' , after : '' , unclosed : true , nodes : [
336
336
{ type : 'word' , sourceIndex : 1 , value : '0' } ,
337
337
{ type : 'space' , sourceIndex : 2 , value : ' ' } ,
338
338
{ type : 'word' , sourceIndex : 3 , value : '32' } ,
@@ -345,9 +345,9 @@ var tests = [{
345
345
message : 'should add unclosed: true prop for every unclosed function' ,
346
346
fixture : '( ( ( ) ' ,
347
347
expected : [
348
- { type : 'function' , value : '' , before : ' ' , after : '' , unclosed : true , nodes : [
349
- { type : 'function' , value : '' , before : ' ' , after : '' , unclosed : true , nodes : [
350
- { type : 'function' , value : '' , before : ' ' , after : '' , nodes : [ ] } ,
348
+ { type : 'function' , sourceIndex : 0 , value : '' , before : ' ' , after : '' , unclosed : true , nodes : [
349
+ { type : 'function' , sourceIndex : 2 , value : '' , before : ' ' , after : '' , unclosed : true , nodes : [
350
+ { type : 'function' , sourceIndex : 4 , value : '' , before : ' ' , after : '' , nodes : [ ] } ,
351
351
{ type : 'space' , sourceIndex : 7 , value : ' ' }
352
352
] }
353
353
] }
@@ -375,11 +375,11 @@ var tests = [{
375
375
message : 'should parse double url and comma' ,
376
376
fixture : 'url(foo/bar.jpg), url(http://website.com/img.jpg)' ,
377
377
expected : [
378
- { type : 'function' , value : 'url' , before : '' , after : '' , nodes : [
378
+ { type : 'function' , sourceIndex : 0 , value : 'url' , before : '' , after : '' , nodes : [
379
379
{ type : 'word' , sourceIndex : 4 , value : 'foo/bar.jpg' }
380
380
] } ,
381
381
{ type : 'div' , value : ',' , before : '' , after : ' ' } ,
382
- { type : 'function' , value : 'url' , before : '' , after : '' , nodes : [
382
+ { type : 'function' , sourceIndex : 18 , value : 'url' , before : '' , after : '' , nodes : [
383
383
{ type : 'word' , sourceIndex : 22 , value : 'http://website.com/img.jpg' }
384
384
] } ,
385
385
]
0 commit comments