-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
autoprefixer.test.js
1179 lines (1042 loc) · 33.4 KB
/
autoprefixer.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
let { equal, match, not, throws, type } = require('uvu/assert')
let { restoreAll, spyOn } = require('nanospy')
let { readFileSync } = require('fs')
let { join } = require('path')
let { test } = require('uvu')
let postcss = require('postcss')
let autoprefixer = require('..')
let grider = autoprefixer({
cascade: false,
grid: 'autoplace',
overrideBrowserslist: ['Chrome 25', 'Edge 12', 'IE 10']
})
let cleaner = autoprefixer({
overrideBrowserslist: []
})
let compiler = autoprefixer({
overrideBrowserslist: ['Chrome 25', 'Opera 12']
})
let filterer = autoprefixer({
overrideBrowserslist: ['Chrome 25', 'Safari 9', 'Firefox 39']
})
let borderer = autoprefixer({
overrideBrowserslist: ['Safari 4', 'Firefox 3.6']
})
let cascader = autoprefixer({
cascade: true,
overrideBrowserslist: ['Chrome > 19', 'Firefox 21', 'IE 10']
})
let keyframer = autoprefixer({
overrideBrowserslist: ['Chrome > 19', 'Opera 12']
})
let flexboxer = autoprefixer({
overrideBrowserslist: ['Chrome > 19', 'Firefox 21', 'IE 10']
})
let without3d = autoprefixer({
overrideBrowserslist: ['Opera 12', 'IE > 0']
})
let supporter = autoprefixer({
overrideBrowserslist: ['Chrome 25', 'Chrome 28', 'IE > 0']
})
let uncascader = autoprefixer({
overrideBrowserslist: ['Firefox 15']
})
let gradienter = autoprefixer({
overrideBrowserslist: ['Chrome 25', 'Opera 12', 'Android 2.3']
})
let grouping = autoprefixer({
grid: 'autoplace',
overrideBrowserslist: ['Chrome 25', 'Firefox > 17', 'IE 10', 'Edge 12']
})
let ffgradienter = autoprefixer({
overrideBrowserslist: ['Chrome 25', 'Opera 12', 'Firefox 6']
})
let selectorer = autoprefixer({
overrideBrowserslist: ['Chrome 25', 'Firefox > 17', 'IE 10', 'Edge 12']
})
let fileSelectorButtoner = autoprefixer({
overrideBrowserslist: ['Chrome > 25', 'Firefox >= 82']
})
let backdroper = autoprefixer({
overrideBrowserslist: ['IE >= 11', 'Chrome < 32', 'Safari >= 15.4']
})
let placeholderShowner = autoprefixer({
overrideBrowserslist: ['IE >= 10']
})
let transitionSpec = autoprefixer({
overrideBrowserslist: ['Chrome > 19', 'Firefox 14', 'IE 10', 'Opera 12']
})
let intrinsicer = autoprefixer({
overrideBrowserslist: ['Chrome 25', 'Firefox 22', 'Safari 10']
})
let imagerender = autoprefixer({
overrideBrowserslist: ['iOS 8', 'iOS 6.1', 'FF 22', 'IE 11', 'Opera 12']
})
let backgrounder = autoprefixer({
overrideBrowserslist: ['Firefox 3.6', 'Android 2.3']
})
let resolutioner = autoprefixer({
overrideBrowserslist: ['Safari 7', 'Opera 12', 'Firefox 15']
})
let overscroller = autoprefixer({
overrideBrowserslist: ['Edge 17']
})
let clipper = autoprefixer({
overrideBrowserslist: ['Safari 7', 'Edge 14']
})
let example = autoprefixer({
overrideBrowserslist: ['defaults']
})
let autofiller = autoprefixer({
overrideBrowserslist: ['Chrome > 90', 'Firefox >= 82']
})
let textDecorator = autoprefixer({
overrideBrowserslist: ['Chrome >= 57', 'Firefox >= 36', 'Safari >= 12.1']
})
let content = autoprefixer({
overrideBrowserslist: [
'> 2%',
'last 2 years',
'ie 11',
'not ie_mob > 0',
'not dead'
]
})
function prefixer(name) {
if (
name === 'grid' ||
name === 'grid-gap' ||
name === 'grid-area' ||
name === 'grid-template' ||
name === 'grid-template-areas'
) {
return grider
} else if (
name === 'filter' ||
name === 'advanced-filter' ||
name === 'element'
) {
return filterer
} else if (
name === 'vendor-hack' ||
name === 'value-hack' ||
name === 'mistakes'
) {
return cleaner
} else if (
name === 'flexbox' ||
name === 'flex-rewrite' ||
name === 'double' ||
name === 'viewport' ||
name === 'appearance'
) {
return flexboxer
} else if (
name === 'intrinsic' ||
name === 'multicolumn' ||
name === 'logical' ||
name === 'text-decoration' ||
name === 'at-rules'
) {
return intrinsicer
} else if (name === 'text-decoration-shorthand') {
return textDecorator
} else if (name === 'selectors' || name === 'placeholder') {
return selectorer
} else if (name === 'selectors' || name === 'file-selector-button') {
return fileSelectorButtoner
} else if (name === 'selectors' || name === 'backdrop') {
return backdroper
} else if (
name === 'selectors' ||
name === 'autofill' ||
name === 'print-color-adjust'
) {
return autofiller
} else if (name === 'placeholder-shown') {
return placeholderShowner
} else if (name === 'backdrop-filter' || name === 'overscroll-behavior') {
return overscroller
} else if (name === 'background-clip' || name === 'user-select') {
return clipper
} else if (name === 'image-rendering' || name === 'writing-mode') {
return imagerender
} else if (name === 'keyframes') {
return keyframer
} else if (name === 'border-radius') {
return borderer
} else if (name === 'gradient') {
return gradienter
} else if (name === 'gradient-fix') {
return ffgradienter
} else if (name === 'grouping-rule') {
return grouping
} else if (name === 'cascade') {
return cascader
} else if (name === '3d-transform') {
return without3d
} else if (name === 'background-size') {
return backgrounder
} else if (name === 'uncascade') {
return uncascader
} else if (name === 'example') {
return example
} else if (name === 'resolution') {
return resolutioner
} else if (name === 'supports') {
return supporter
} else if (name === 'transition-spec') {
return transitionSpec
} else if (name === 'content') {
return content
} else {
return compiler
}
}
function read(name) {
let file = join(__dirname, '/cases/' + name + '.css')
return readFileSync(file).toString()
}
function universalizer(string) {
return string.replace(/\r/g, '')
}
function check(from, instance = prefixer(from)) {
let input = read(from)
let output = read(from + '.out')
let result = postcss([instance]).process(input)
equal(result.warnings().length, 0)
equal(universalizer(result.css), universalizer(output))
}
const COMMONS = [
'transition',
'values',
'keyframes',
'gradient',
'flex-rewrite',
'flexbox',
'filter',
'border-image',
'border-radius',
'notes',
'selectors',
'placeholder',
'placeholder-shown',
'fullscreen',
'intrinsic',
'mistakes',
'custom-prefix',
'cascade',
'double',
'multicolumn',
'3d-transform',
'background-size',
'supports',
'viewport',
'resolution',
'logical',
'appearance',
'advanced-filter',
'element',
'image-set',
'image-rendering',
'mask-border',
'writing-mode',
'cross-fade',
'gradient-fix',
'text-emphasis-position',
'grid',
'grid-area',
'grid-template',
'grid-template-areas',
'grid-gap',
'print-color-adjust'
]
test.after.each(() => {
delete process.env.AUTOPREFIXER_GRID
restoreAll()
})
test('throws on wrong options', () => {
throws(() => {
autoprefixer({ browser: ['chrome 25', 'opera 12'] })
}, /overrideBrowserslist/)
throws(() => {
autoprefixer({
browserslist: ['chrome 25', 'opera 12']
})
}, /overrideBrowserslist/)
})
let options = {
cascade: false,
grid: false
}
let browsers = ['chrome 25', 'opera 12']
test('sets options via options object', () => {
let allOptions = Object.assign(options, { overrideBrowserslist: browsers })
let instance = autoprefixer(allOptions)
equal(instance.options, allOptions)
equal(instance.browsers, browsers)
})
test('sets options via array of browsers as first argument and object', () => {
let instance = autoprefixer(browsers, options)
equal(instance.options, options)
equal(instance.browsers, browsers)
})
test('sets options via browsers as arguments and options object', () => {
let instance = autoprefixer(...browsers, options)
equal(instance.options, options)
equal(instance.browsers, browsers)
})
test('has default browsers', () => {
type(autoprefixer.defaults.length, 'number')
})
test('shows warning on browsers option', () => {
let consoleWarn = spyOn(console, 'warn', () => {})
let instance = autoprefixer({
browsers: ['last 1 version']
})
equal(instance.browsers, ['last 1 version'])
equal(consoleWarn.callCount, 1)
match(consoleWarn.calls[0][0], 'overrideBrowserslist')
})
test('passes statistics to Browserslist', () => {
let stats = {
chrome: {
10: 10,
11: 40
},
ie: {
10: 10,
11: 40
}
}
match(
autoprefixer({
overrideBrowserslist: '> 20% in my stats',
stats
}).info(),
/Browsers:\n\s\sChrome: 11\n\s\sIE: 11\n/
)
})
test('prefixes values', () => {
check('values')
})
test('prefixes @keyframes', () => {
check('keyframes')
})
test('prefixes @viewport', () => {
check('viewport')
})
test('prefixes selectors', () => {
check('selectors')
})
test('prefixes resolution query', () => {
check('resolution')
})
test('removes common mistakes', () => {
check('mistakes')
})
test('reads notes for prefixes', () => {
check('notes')
})
test('keeps vendor-specific hacks', () => {
check('vendor-hack')
})
test('keeps values with vendor hacks', () => {
check('value-hack')
})
test('works with comments', () => {
check('comments')
})
test('uses visual cascade', () => {
check('cascade')
})
test('works with properties near', () => {
check('double')
})
test('checks prefixed in hacks', () => {
check('check-down')
})
test('normalize cascade after remove', () => {
check('uncascade')
})
test('prefix decls in @supports', () => {
check('supports')
})
test('saves declaration style', () => {
check('style')
})
test('uses ignore next control comments', () => {
check('ignore-next')
})
test('uses block control comments', () => {
check('disabled')
})
test('has actual example in docs', () => {
check('example')
})
test('process grouping rules correctly', () => {
check('grouping-rule')
})
test('transition on vendor specific rule', () => {
check('transition-spec')
})
test('ignore prefix in vendor at rules', () => {
check('at-rules')
})
test('ignore content property', () => {
let input = read('content')
let result = postcss([prefixer('scope')]).process(input)
equal(result.css, input)
})
test('uses control comments to whole scope', () => {
let input = read('scope')
let output = read('scope.out')
let result = postcss([prefixer('scope')]).process(input)
equal(result.css, output)
equal(
result.warnings().map(i => i.toString()),
[
'autoprefixer: <css input>:5:3: Second Autoprefixer control comment ' +
'was ignored. Autoprefixer applies control comment to whole block, ' +
'not to next rules.'
]
)
})
test('sets grid option via comment', () => {
let input = read('grid-status')
let output = read('grid-status.out')
let ap = autoprefixer({ overrideBrowserslist: ['last 2 versions', 'IE 11'] })
let result = postcss([ap]).process(input)
equal(result.css, output)
equal(
result.warnings().map(i => i.toString()),
[
'autoprefixer: <css input>:2:1: Second Autoprefixer grid control ' +
'comment was ignored. Autoprefixer applies control comments ' +
'to the whole block, not to the next rules.',
'autoprefixer: <css input>:20:3: Second Autoprefixer grid control ' +
'comment was ignored. Autoprefixer applies control comments ' +
'to the whole block, not to the next rules.',
'autoprefixer: <css input>:47:3: Second Autoprefixer grid control ' +
'comment was ignored. Autoprefixer applies control comments ' +
'to the whole block, not to the next rules.'
]
)
})
test('prefixes transition', () => {
let input = read('transition')
let output = read('transition.out')
let result = postcss([prefixer('transition')]).process(input)
equal(result.css, output)
equal(
result.warnings().map(i => i.toString()),
[
'autoprefixer: <css input>:23:3: Replace transition-property ' +
'to transition, because Autoprefixer could not support any cases ' +
'of transition-property and other transition-*'
]
)
})
test('does not raise unnecessary warnings when prefixing transition', () => {
check('transition-no-warning')
})
test('works with broken transition', () => {
let input = 'a{transition:,,}'
let output = 'a{-webkit-transition:;-o-transition:;transition:}'
let result = postcss([prefixer('transition')]).process(input)
equal(result.css, output)
})
test('should ignore spaces inside values', () => {
let css = read('trim')
equal(postcss([flexboxer]).process(css).css, css)
})
test('removes unnecessary prefixes', () => {
let processor = postcss([cleaner])
for (let i of COMMONS) {
if (i === 'gradient-fix') continue
if (i === 'cascade') continue
if (i === 'mistakes') continue
if (i === 'flex-rewrite') continue
if (i === 'grid') continue
if (i === 'grid-gap') continue
if (i === 'grid-area') continue
if (i === 'grid-template') continue
if (i === 'grid-template-areas') continue
let input = read(i + '.out')
let output = read(i)
equal(processor.process(input).css, output)
}
})
test('media does not should nested', () => {
let processor = postcss([grider])
let input = read('grid-media-rules')
let output = read('grid-media-rules.out')
equal(processor.process(input).css, output)
})
test('does not remove unnecessary prefixes on request', () => {
for (let i of ['transition', 'values', 'fullscreen']) {
let keeper = autoprefixer({ overrideBrowserslist: [], remove: false })
let css = read(i + '.out')
equal(postcss([keeper]).process(css).css, css)
}
})
test('does not add prefixes on request', () => {
for (let i of ['transition', 'values', 'fullscreen']) {
let remover = autoprefixer({
add: false,
overrideBrowserslist: ['Opera 12']
})
let unprefixed = read(i)
equal(postcss([remover]).process(unprefixed).css, unprefixed)
}
})
test('prevents doubling prefixes', () => {
for (let i of COMMONS) {
let processor = postcss([prefixer(i)])
let input = read(i)
let output = read(i + '.out')
let result = processor.process(processor.process(input)).css
equal(universalizer(result), universalizer(output))
}
})
function isContainerNode(node) {
return 'nodes' in node
}
test('does not broke AST', () => {
function checkParent(node) {
node.walk(child => {
type(child.parent, 'object')
if (isContainerNode(child)) checkParent(child)
})
}
for (let i of COMMONS) {
let processor = postcss([prefixer(i)])
let input = read(i)
checkParent(processor.process(input).root)
}
})
test('parses difficult files', () => {
let input = read('syntax')
let result = postcss([cleaner]).process(input)
equal(result.css, input)
})
test('marks parsing errors', () => {
throws(() => {
postcss([cleaner]).process('a {').css
}, '<css input>:1:1: Unclosed block')
})
test('shows file name in parse error', () => {
throws(() => {
postcss([cleaner]).process('a {', { from: 'a.css' }).css
}, /a.css:1:1: /)
})
test('uses browserslist config', () => {
let from = join(__dirname, 'cases/config/test.css')
let input = read('config/test')
let output = read('config/test.out')
let processor = postcss([autoprefixer])
equal(processor.process(input, { from }).css, output)
})
test('sets browserslist environment', () => {
let from = join(__dirname, 'cases/config/test.css')
let input = read('config/test')
let output = read('config/test.production')
let processor = postcss([autoprefixer({ env: 'development' })])
equal(processor.process(input, { from }).css, output)
})
test('takes values from other PostCSS plugins', () => {
function plugin(root) {
root.walkDecls(i => {
i.value = 'calc(0)'
})
}
let result = postcss([plugin, compiler]).process('a{width:0/**/0}')
equal(result.css, 'a{width:-webkit-calc(0);width:calc(0)}')
})
test('has option to disable @supports support', () => {
let css = '@supports (cursor: grab) {}'
let instance = autoprefixer({
overrideBrowserslist: ['Chrome 28'],
supports: false
})
let result = postcss([instance]).process(css)
equal(result.css, css)
})
test('has disabled grid options by default', () => {
let ap = autoprefixer({ overrideBrowserslist: ['Edge 12', 'IE 10'] })
let input = read('grid')
let output = read('grid.disabled')
let result = postcss([ap]).process(input)
equal(result.css, output)
})
test('has different outputs for different grid options', () => {
function ap(gridValue) {
return autoprefixer({
grid: gridValue,
overrideBrowserslist: ['Edge 12', 'IE 10']
})
}
let input = read('grid-options')
let outputAutoplace = read('grid-options.autoplace.out')
let outputNoAutoplace = read('grid-options.no-autoplace.out')
let outputDisabled = read('grid-options.disabled.out')
let resultAutoplace = postcss([ap('autoplace')]).process(input).css
let resultNoAutoplace = postcss([ap('no-autoplace')]).process(input).css
let resultEnabled = postcss([ap(true)]).process(input).css
let resultDisabled = postcss([ap(false)]).process(input).css
// output for grid: 'autoplace'
equal(resultAutoplace, outputAutoplace)
// output for grid: 'no-autoplace'
equal(resultNoAutoplace, outputNoAutoplace)
// output for grid: true is the same as for 'no-autoplace'
equal(resultEnabled, outputNoAutoplace)
// output for grid: false
equal(resultDisabled, outputDisabled)
})
test('has different outputs for different grid environment variables', () => {
function ap(gridValue) {
process.env.AUTOPREFIXER_GRID = gridValue
return autoprefixer({ overrideBrowserslist: ['Edge 12', 'IE 10'] })
}
let input = read('grid-options')
let outputAutoplace = read('grid-options.autoplace.out')
let outputNoAutoplace = read('grid-options.no-autoplace.out')
let resultAutoplace = postcss([ap('autoplace')]).process(input).css
equal(resultAutoplace, outputAutoplace)
let resultNoAutoplace = postcss([ap('no-autoplace')]).process(input).css
equal(resultNoAutoplace, outputNoAutoplace)
})
test('has option to disable flexbox support', () => {
let css = read('flexbox')
let instance = autoprefixer({
flexbox: false,
overrideBrowserslist: ['IE 10']
})
let result = postcss([instance]).process(css)
equal(result.css, css)
})
test('has option to disable 2009 flexbox support', () => {
let ap = autoprefixer({
flexbox: 'no-2009',
overrideBrowserslist: ['Chrome > 19']
})
let css = 'a{flex:1;transition:flex}'
let result = postcss([ap]).process(css)
equal(
result.css,
'a{' +
'-webkit-flex:1;flex:1;' +
'-webkit-transition:-webkit-flex;transition:-webkit-flex;' +
'transition:flex;transition:flex, -webkit-flex' +
'}'
)
})
test('returns inspect string', () => {
match(
autoprefixer({ overrideBrowserslist: ['chrome 25'] }).info(),
/Browsers:\s+Chrome: 25/
)
})
test('uses browserslist config in inspect', () => {
let from = join(__dirname, 'cases/config')
match(autoprefixer().info({ from }), /Browsers:\s+IE: 10/)
})
test('ignores unknown versions on request', () => {
throws(() => {
autoprefixer({ overrideBrowserslist: ['ie 100'] }).info()
}, /Unknown version 100 of ie/)
not.throws(() => {
autoprefixer({
ignoreUnknownVersions: true,
overrideBrowserslist: ['ie 100']
}).info()
})
})
test('works with CSS Modules', () => {
postcss([autoprefixer()]).process(':export { selectors: _1q6ho_2 }').css
})
test('ignores prefix IE filter', () => {
check('filter')
})
test('supports webkit filters', () => {
check('advanced-filter')
})
test('changes border image syntax', () => {
check('border-image')
})
test('supports old Mozilla prefixes', () => {
check('border-radius')
})
test('supports all flexbox syntaxes', () => {
check('flexbox')
})
test('supports map flexbox props', () => {
check('flex-rewrite')
})
test('supports all fullscreens', () => {
check('fullscreen')
})
test('supports file-selector-button', () => {
check('file-selector-button')
})
test('supports ::backdrop', () => {
check('backdrop')
})
test('supports custom prefixes', () => {
check('custom-prefix')
})
test('fixes break properties', () => {
check('multicolumn')
})
test('ignores some 3D transforms', () => {
check('3d-transform')
})
test('supports background-size', () => {
check('background-size')
})
test('supports background-clip', () => {
check('background-clip')
})
test('supports logical properties', () => {
check('logical')
})
test('supports appearance', () => {
check('appearance')
})
test('supports all placeholders', () => {
check('placeholder')
})
test('supports placeholder-shown', () => {
check('placeholder-shown')
})
test('supports image-rendering', () => {
check('image-rendering')
})
test('supports border-box mask', () => {
check('mask-border')
})
test('supports mask-composite', () => {
check('mask-composite')
})
test('supports image-set()', () => {
check('image-set')
})
test('supports writing-mode', () => {
check('writing-mode')
})
test('supports cross-fade()', () => {
check('cross-fade')
})
test('ignores modern direction', () => {
check('animation')
})
test('supports overscroll-behavior', () => {
check('overscroll-behavior')
})
test('supports print-color-adjust', () => {
let input = read('print-color-adjust')
let output = read('print-color-adjust.out')
let result = postcss([prefixer('print-color-adjust')]).process(input)
equal(result.css, output)
equal(
result.warnings().map(i => i.toString()),
[
'autoprefixer: <css input>:2:3: Replace color-adjust ' +
'to print-color-adjust. The color-adjust shorthand ' +
'is currently deprecated.'
]
)
})
test('supports backdrop-filter', () => {
check('backdrop-filter')
})
test('supports user-select hack for IE', () => {
check('user-select')
})
test('supports appearance for IE', () => {
let instance = autoprefixer({ overrideBrowserslist: 'Edge 15' })
let result = postcss([instance]).process('a { appearance: none }')
equal(result.css, 'a { -webkit-appearance: none; appearance: none }')
})
test('changes angle in gradient', () => {
let input = read('gradient')
let output = read('gradient.out')
let result = postcss([prefixer('gradient')]).process(input)
equal(result.css, output)
equal(
result.warnings().map(i => i.toString()),
[
'autoprefixer: <css input>:18:3: Gradient has outdated direction ' +
'syntax. New syntax is like `closest-side at 0 0` instead of ' +
'`0 0, closest-side`.',
'autoprefixer: <css input>:38:3: Gradient has outdated direction ' +
'syntax. New syntax is like `to left` instead of `right`.',
'autoprefixer: <css input>:100:3: Gradient has outdated ' +
'direction syntax. Replace `cover` to `farthest-corner`.',
'autoprefixer: <css input>:104:3: Gradient has outdated ' +
'direction syntax. Replace `contain` to `closest-side`.'
]
)
check('gradient-fix')
})
test('warns on old flexbox display', () => {
let result = postcss([flexboxer]).process('a{ display: box; }')
equal(result.css, 'a{ display: box; }')
equal(
result.warnings().map(i => i.toString()),
[
'autoprefixer: <css input>:1:4: You should write display: flex ' +
'by final spec instead of display: box'
]
)
})
test('supports intrinsic sizing', () => {
let input = read('intrinsic')
let output = read('intrinsic.out')
let result = postcss([prefixer('intrinsic')]).process(input)
equal(result.css, output)
equal(
result.warnings().map(i => i.toString()),
[
'autoprefixer: <css input>:15:3: Replace fill to stretch, ' +
'because spec had been changed',
'autoprefixer: <css input>:19:3: Replace fill-available ' +
'to stretch, because spec had been changed'
]
)
})
test('supports text-emphasis', () => {
let input = read('text-emphasis-position')
let output = read('text-emphasis-position.out')
let instance = prefixer('text-emphasis-position')
let result = postcss([instance]).process(input)
equal(result.css, output)
equal(
result.warnings().map(i => i.toString()),
[
'autoprefixer: <css input>:14:3: You should use 2 values ' +
'for text-emphasis-position For example, `under left` ' +
'instead of just `under`.'
]
)
})
test('supports grid layout', () => {
let input = read('grid')
let output = read('grid.out')
let instance = prefixer('grid')
let result = postcss([instance]).process(input)
equal(result.css, output)
equal(
result.warnings().map(i => i.toString()),
[
'autoprefixer: <css input>:3:3: Autoplacement does not work ' +
'without grid-template-rows property',
'autoprefixer: <css input>:12:3: Autoplacement does not work ' +
'without grid-template-columns property',
'autoprefixer: <css input>:36:3: Can not prefix grid-column-end ' +
'(grid-column-start is not found)',
'autoprefixer: <css input>:37:3: IE does not support subgrid',
'autoprefixer: <css input>:39:3: Can not implement grid-gap ' +
'without grid-template-columns',
'autoprefixer: <css input>:39:3: Can not find grid areas: ' +
'head, nav, main, foot',
'autoprefixer: <css input>:57:3: Can not implement grid-gap ' +
'without grid-template-columns',
'autoprefixer: <css input>:57:3: Can not find grid areas: a',
'autoprefixer: <css input>:65:3: Can not implement grid-gap ' +
'without grid-template-columns',
'autoprefixer: <css input>:65:3: Can not find grid areas: b',
'autoprefixer: <css input>:73:3: Can not find grid areas: c',
'autoprefixer: <css input>:81:3: Can not find grid areas: d',
'autoprefixer: <css input>:116:3: grid-column-span is not part ' +
'of final Grid Layout. Use grid-column.',
'autoprefixer: <css input>:117:3: grid-row-span is not part ' +
'of final Grid Layout. Use grid-row.',
'autoprefixer: <css input>:118:3: grid-auto-columns is not ' +
'supported by IE',
'autoprefixer: <css input>:119:3: grid-auto-rows is not ' +
'supported by IE',
'autoprefixer: <css input>:121:33: auto-fill value is not ' +
'supported by IE',
'autoprefixer: <css input>:122:30: auto-fit value is not ' +
'supported by IE',
'autoprefixer: <css input>:138:3: Please do not use ' +
'display: contents; if you have grid setting enabled',
'autoprefixer: <css input>:142:3: IE does not support align-items ' +
'on grid containers. Try using align-self on child elements instead: ' +
'.warn_ie_align > * { align-self: center }',
'autoprefixer: <css input>:147:3: IE does not support justify-items ' +
'on grid containers. Try using justify-self on child elements ' +
'instead: .warn_ie_justify > * { justify-self: center }',
'autoprefixer: <css input>:152:3: IE does not support justify-content ' +
'on grid containers',
'autoprefixer: <css input>:157:3: IE does not support place-items ' +
'on grid containers. Try using place-self on child elements ' +
'instead: .warn_place_items > * { place-self: start end }',
'autoprefixer: <css input>:181:3: grid-auto-flow is not supported by IE',
'autoprefixer: <css input>:203:26: Autoprefixer currently does not ' +
'support line names. Try using grid-template-areas instead.'
]
)
let input2 = read('grid-template')