@@ -9,35 +9,35 @@ var tests = [{
9
9
message : 'should process escaped parentheses (open)' ,
10
10
fixture : '\\(' ,
11
11
expected : [
12
- { type : 'word' , value : '\\(' }
12
+ { type : 'word' , sourceIndex : 0 , value : '\\(' }
13
13
]
14
14
} , {
15
15
message : 'should process escaped parentheses (close)' ,
16
16
fixture : '\\)' ,
17
17
expected : [
18
- { type : 'word' , value : '\\)' }
18
+ { type : 'word' , sourceIndex : 0 , value : '\\)' }
19
19
]
20
20
} , {
21
21
message : 'should process escaped parentheses (both)' ,
22
22
fixture : '\\(\\)' ,
23
23
expected : [
24
- { type : 'word' , value : '\\(\\)' }
24
+ { type : 'word' , sourceIndex : 0 , value : '\\(\\)' }
25
25
]
26
26
} , {
27
27
message : 'should process escaped parentheses (both)' ,
28
28
fixture : '\\( \\)' ,
29
29
expected : [
30
- { type : 'word' , value : '\\(' } ,
30
+ { type : 'word' , sourceIndex : 0 , value : '\\(' } ,
31
31
{ type : 'space' , sourceIndex : 2 , value : ' ' } ,
32
- { type : 'word' , value : '\\)' }
32
+ { type : 'word' , sourceIndex : 3 , value : '\\)' }
33
33
]
34
34
} , {
35
35
message : 'should process unopened parentheses as word' ,
36
36
fixture : '() )wo)rd)' ,
37
37
expected : [
38
38
{ type : 'function' , value : '' , before : '' , after : '' , nodes : [ ] } ,
39
39
{ type : 'space' , sourceIndex : 2 , value : ' ' } ,
40
- { type : 'word' , value : ')wo)rd)' }
40
+ { type : 'word' , sourceIndex : 3 , value : ')wo)rd)' }
41
41
]
42
42
} , {
43
43
message : 'should add before prop' ,
@@ -50,7 +50,7 @@ var tests = [{
50
50
fixture : '( | )' ,
51
51
expected : [
52
52
{ type : 'function' , value : '' , before : ' ' , after : ' ' , nodes : [
53
- { type : 'word' , value : '|' }
53
+ { type : 'word' , sourceIndex : 2 , value : '|' }
54
54
] }
55
55
]
56
56
} , {
@@ -78,7 +78,7 @@ var tests = [{
78
78
{ type : 'function' , value : '' , before : ' ' , after : '' , nodes : [ ] }
79
79
] }
80
80
] } ,
81
- { type : 'word' , value : 'word' }
81
+ { type : 'word' , sourceIndex : 13 , value : 'word' }
82
82
]
83
83
} , {
84
84
message : 'should process divider (/)' ,
@@ -177,9 +177,9 @@ var tests = [{
177
177
message : 'should process quoted strings and words' ,
178
178
fixture : 'word1"string"word2' ,
179
179
expected : [
180
- { type : 'word' , value : 'word1' } ,
180
+ { type : 'word' , sourceIndex : 0 , value : 'word1' } ,
181
181
{ type : 'string' , sourceIndex : 5 , value : 'string' , quote : '"' } ,
182
- { type : 'word' , value : 'word2' }
182
+ { type : 'word' , sourceIndex : 13 , value : 'word2' }
183
183
]
184
184
} , {
185
185
message : 'should process quoted strings and spaces' ,
@@ -194,55 +194,55 @@ var tests = [{
194
194
fixture : ' \\"word\\\'\\ \\\t ' ,
195
195
expected : [
196
196
{ type : 'space' , sourceIndex : 0 , value : ' ' } ,
197
- { type : 'word' , value : '\\"word\\\'\\ \\\t' } ,
197
+ { type : 'word' , sourceIndex : 1 , value : '\\"word\\\'\\ \\\t' } ,
198
198
{ type : 'space' , sourceIndex : 13 , value : ' ' }
199
199
]
200
200
} , {
201
201
message : 'should correctly proceess font value' ,
202
202
fixture : 'bold italic 12px \t /3 \'Open Sans\', Arial, "Helvetica Neue", sans-serif' ,
203
203
expected : [
204
- { type : 'word' , value : 'bold' } ,
204
+ { type : 'word' , sourceIndex : 0 , value : 'bold' } ,
205
205
{ type : 'space' , sourceIndex : 4 , value : ' ' } ,
206
- { type : 'word' , value : 'italic' } ,
206
+ { type : 'word' , sourceIndex : 5 , value : 'italic' } ,
207
207
{ type : 'space' , sourceIndex : 11 , value : ' ' } ,
208
- { type : 'word' , value : '12px' } ,
208
+ { type : 'word' , sourceIndex : 12 , value : '12px' } ,
209
209
{ type : 'div' , value : '/' , before : ' \t ' , after : '' } ,
210
- { type : 'word' , value : '3' } ,
210
+ { type : 'word' , sourceIndex : 20 , value : '3' } ,
211
211
{ type : 'space' , sourceIndex : 21 , value : ' ' } ,
212
212
{ type : 'string' , sourceIndex : 22 , value : 'Open Sans' , quote : '\'' } ,
213
213
{ type : 'div' , value : ',' , before : '' , after : ' ' } ,
214
- { type : 'word' , value : 'Arial' } ,
214
+ { type : 'word' , sourceIndex : 35 , value : 'Arial' } ,
215
215
{ type : 'div' , value : ',' , before : '' , after : ' ' } ,
216
216
{ type : 'string' , sourceIndex : 42 , value : 'Helvetica Neue' , quote : '"' } ,
217
217
{ type : 'div' , value : ',' , before : '' , after : ' ' } ,
218
- { type : 'word' , value : 'sans-serif' } ,
218
+ { type : 'word' , sourceIndex : 60 , value : 'sans-serif' } ,
219
219
]
220
220
} , {
221
221
message : 'should correctly proceess color value' ,
222
222
fixture : 'rgba( 29, 439 , 29 )' ,
223
223
expected : [
224
224
{ type : 'function' , value : 'rgba' , before : ' ' , after : ' ' , nodes : [
225
- { type : 'word' , value : '29' } ,
226
- { type : 'div' , value : ',' , before : '' , after : ' ' } ,
227
- { type : 'word' , value : '439' } ,
228
- { type : 'div' , value : ',' , before : ' ' , after : ' ' } ,
229
- { type : 'word' , value : '29' } ,
225
+ { type : 'word' , sourceIndex : 6 , value : '29' } ,
226
+ { type : 'div' , value : ',' , before : '' , after : ' ' } ,
227
+ { type : 'word' , sourceIndex : 10 , value : '439' } ,
228
+ { type : 'div' , value : ',' , before : ' ' , after : ' ' } ,
229
+ { type : 'word' , sourceIndex : 16 , value : '29' } ,
230
230
] }
231
231
]
232
232
} , {
233
233
message : 'should correctly process url function' ,
234
234
fixture : 'url( /gfx/img/bg.jpg )' ,
235
235
expected : [
236
236
{ type : 'function' , value : 'url' , before : ' ' , after : ' ' , nodes : [
237
- { type : 'word' , value : '/gfx/img/bg.jpg' }
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
244
{ type : 'function' , value : 'url' , before : ' ' , after : '' , unclosed : true , nodes : [
245
- { type : 'word' , value : '/gfx/img/bg.jpg' } ,
245
+ { type : 'word' , sourceIndex : 5 , value : '/gfx/img/bg.jpg' } ,
246
246
{ type : 'space' , sourceIndex : 20 , value : ' ' }
247
247
] }
248
248
]
@@ -253,7 +253,7 @@ var tests = [{
253
253
{ type : 'function' , 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
- { type : 'word' , value : 'hello' }
256
+ { type : 'word' , sourceIndex : 23 , value : 'hello' }
257
257
] }
258
258
]
259
259
} , {
@@ -263,45 +263,45 @@ var tests = [{
263
263
{ type : 'function' , value : 'calc' , before : '' , after : '' , nodes : [
264
264
{ type : 'function' , value : '' , before : '' , after : '' , nodes : [
265
265
{ type : 'function' , value : '' , before : '' , after : '' , nodes : [
266
- { type : 'word' , value : '768px' } ,
266
+ { type : 'word' , sourceIndex : 7 , value : '768px' } ,
267
267
{ type : 'space' , sourceIndex : 12 , value : ' ' } ,
268
- { type : 'word' , value : '-' } ,
268
+ { type : 'word' , sourceIndex : 13 , value : '-' } ,
269
269
{ type : 'space' , sourceIndex : 14 , value : ' ' } ,
270
- { type : 'word' , value : '100vw' }
270
+ { type : 'word' , sourceIndex : 15 , value : '100vw' }
271
271
] } ,
272
272
{ type : 'div' , value : '/' , before : ' ' , after : ' ' } ,
273
- { type : 'word' , value : '2' }
273
+ { type : 'word' , sourceIndex : 24 , value : '2' }
274
274
] } ,
275
275
{ type : 'space' , sourceIndex : 26 , value : ' ' } ,
276
- { type : 'word' , value : '-' } ,
276
+ { type : 'word' , sourceIndex : 27 , value : '-' } ,
277
277
{ type : 'space' , sourceIndex : 28 , value : ' ' } ,
278
- { type : 'word' , value : '15px' }
278
+ { type : 'word' , sourceIndex : 29 , value : '15px' }
279
279
] }
280
280
]
281
281
} , {
282
282
message : 'should process colons with params' ,
283
283
fixture : '(min-width: 700px) and (orientation: \\$landscape)' ,
284
284
expected : [
285
285
{ type : 'function' , value : '' , before : '' , after : '' , nodes : [
286
- { type : 'word' , value : 'min-width' } ,
286
+ { type : 'word' , sourceIndex : 1 , value : 'min-width' } ,
287
287
{ type : 'div' , value : ':' , before : '' , after : ' ' } ,
288
- { type : 'word' , value : '700px' }
288
+ { type : 'word' , sourceIndex : 12 , value : '700px' }
289
289
] } ,
290
290
{ type : 'space' , sourceIndex : 18 , value : ' ' } ,
291
- { type : 'word' , value : 'and' } ,
291
+ { type : 'word' , sourceIndex : 19 , value : 'and' } ,
292
292
{ type : 'space' , sourceIndex : 22 , value : ' ' } ,
293
293
{ type : 'function' , value : '' , before : '' , after : '' , nodes : [
294
- { type : 'word' , value : 'orientation' } ,
294
+ { type : 'word' , sourceIndex : 24 , value : 'orientation' } ,
295
295
{ type : 'div' , value : ':' , before : '' , after : ' ' } ,
296
- { type : 'word' , value : '\\$landscape' }
296
+ { type : 'word' , sourceIndex : 37 , value : '\\$landscape' }
297
297
] }
298
298
]
299
299
} , {
300
300
message : 'should escape parentheses with backslash' ,
301
301
fixture : 'url( http://website.com/assets\\)_test )' ,
302
302
expected : [
303
303
{ type : 'function' , value : 'url' , before : ' ' , after : ' ' , nodes : [
304
- { type : 'word' , value : 'http://website.com/assets\\)_test' }
304
+ { type : 'word' , sourceIndex : 5 , value : 'http://website.com/assets\\)_test' }
305
305
] }
306
306
]
307
307
} , {
@@ -310,34 +310,34 @@ var tests = [{
310
310
expected : [
311
311
{ type : 'function' , value : 'fn1' , before : '' , after : '' , nodes : [
312
312
{ type : 'function' , value : 'fn2' , before : '' , after : '' , nodes : [
313
- { type : 'word' , value : '255' }
313
+ { type : 'word' , sourceIndex : 8 , value : '255' }
314
314
] } ,
315
315
{ type : 'div' , value : ',' , before : '' , after : ' ' } ,
316
316
{ type : 'function' , value : 'fn3' , before : '' , after : '' , nodes : [
317
- { type : 'word' , value : '.2' }
317
+ { type : 'word' , sourceIndex : 18 , value : '.2' }
318
318
] } ,
319
319
] } ,
320
320
{ type : 'div' , value : ',' , before : '' , after : ' ' } ,
321
321
{ type : 'function' , value : 'fn4' , before : '' , after : '' , nodes : [
322
322
{ type : 'function' , value : 'fn5' , before : '' , after : '' , nodes : [
323
- { type : 'word' , value : '255' } ,
323
+ { type : 'word' , sourceIndex : 32 , value : '255' } ,
324
324
{ type : 'div' , value : ',' , before : '' , after : '' } ,
325
- { type : 'word' , value : '.2' }
325
+ { type : 'word' , sourceIndex : 36 , value : '.2' }
326
326
] } ,
327
327
{ type : 'div' , value : ',' , before : '' , after : ' ' } ,
328
- { type : 'word' , value : 'fn6' }
328
+ { type : 'word' , sourceIndex : 41 , value : 'fn6' }
329
329
] }
330
330
]
331
331
} , {
332
332
message : 'shouldn\'t throw an error on unclosed function' ,
333
333
fixture : '(0 32 word ' ,
334
334
expected : [
335
335
{ type : 'function' , value : '' , before : '' , after : '' , unclosed : true , nodes : [
336
- { type : 'word' , value : '0' } ,
336
+ { type : 'word' , sourceIndex : 1 , value : '0' } ,
337
337
{ type : 'space' , sourceIndex : 2 , value : ' ' } ,
338
- { type : 'word' , value : '32' } ,
338
+ { type : 'word' , sourceIndex : 3 , value : '32' } ,
339
339
{ type : 'space' , sourceIndex : 5 , value : ' ' } ,
340
- { type : 'word' , value : 'word' } ,
340
+ { type : 'word' , sourceIndex : 6 , value : 'word' } ,
341
341
{ type : 'space' , sourceIndex : 10 , value : ' ' }
342
342
] }
343
343
]
@@ -356,31 +356,31 @@ var tests = [{
356
356
message : 'shouldn\'t throw an error on unopened function' ,
357
357
fixture : '0 32 word ) ' ,
358
358
expected : [
359
- { type : 'word' , value : '0' } ,
359
+ { type : 'word' , sourceIndex : 0 , value : '0' } ,
360
360
{ type : 'space' , sourceIndex : 1 , value : ' ' } ,
361
- { type : 'word' , value : '32' } ,
361
+ { type : 'word' , sourceIndex : 2 , value : '32' } ,
362
362
{ type : 'space' , sourceIndex : 4 , value : ' ' } ,
363
- { type : 'word' , value : 'word' } ,
363
+ { type : 'word' , sourceIndex : 5 , value : 'word' } ,
364
364
{ type : 'space' , sourceIndex : 9 , value : ' ' } ,
365
- { type : 'word' , value : ')' } ,
365
+ { type : 'word' , sourceIndex : 10 , value : ')' } ,
366
366
{ type : 'space' , sourceIndex : 11 , value : ' ' }
367
367
]
368
368
} , {
369
369
message : 'should process escaped spaces as word in fonts' ,
370
370
fixture : 'Bond\\ 007' ,
371
371
expected : [
372
- { type : 'word' , value : 'Bond\\ 007' }
372
+ { type : 'word' , sourceIndex : 0 , value : 'Bond\\ 007' }
373
373
]
374
374
} , {
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
378
{ type : 'function' , value : 'url' , before : '' , after : '' , nodes : [
379
- { type : 'word' , value : 'foo/bar.jpg' }
379
+ { type : 'word' , sourceIndex : 4 , value : 'foo/bar.jpg' }
380
380
] } ,
381
381
{ type : 'div' , value : ',' , before : '' , after : ' ' } ,
382
382
{ type : 'function' , value : 'url' , before : '' , after : '' , nodes : [
383
- { type : 'word' , value : 'http://website.com/img.jpg' }
383
+ { type : 'word' , sourceIndex : 22 , value : 'http://website.com/img.jpg' }
384
384
] } ,
385
385
]
386
386
} ] ;
0 commit comments