-
-
Notifications
You must be signed in to change notification settings - Fork 319
/
postcss-colormin.js
96 lines (80 loc) · 2.3 KB
/
postcss-colormin.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
'use strict';
const { test } = require('uvu');
const processCss = require('./_processCss');
test(
'should minify color values in background gradients (preset)',
processCss(
'h1{background:linear-gradient( #ff0000,yellow )}',
'h1{background:linear-gradient(red,#ff0)}'
)
);
test(
'should minify color values in background gradients (2) (preset)',
processCss(
'h1{background:linear-gradient(yellow, orange), linear-gradient(black, rgba(255, 255, 255, 0))}',
'h1{background:linear-gradient(#ff0,orange),linear-gradient(#000,hsla(0,0%,100%,0))}'
)
);
test(
'should minify color values in background gradients (3) (preset)',
processCss(
'h1{background:linear-gradient(0deg, yellow, black 40%, red)}',
'h1{background:linear-gradient(0deg,#ff0,#000 40%,red)}'
)
);
test(
'should minify color values (10)',
processCss(
'h1{text-shadow: 1px 1px 1px #F0FFFF, 1px 1px 1px #F0FFFF}',
'h1{text-shadow:1px 1px 1px azure,1px 1px 1px azure}'
)
);
test(
'should bail on the "composes" property',
processCss.passthrough('h1{composes:black from "styles"}')
);
test(
'should not mangle empty strings',
processCss.passthrough('h1{content:""}')
);
test(
'should passthrough css variables',
processCss.passthrough('h1{color:var(--foo)}')
);
test(
'should passthrough css variables #2',
processCss.passthrough('h1{color:var(--foo) var(--bar)}')
);
test(
'should passthrough css variables #3',
processCss.passthrough('h1{color:rgb(var(--foo),255,255)}')
);
test(
'should passthrough css variables #4',
processCss.passthrough('h1{color:rgb(255,var(--bar),255)}')
);
test(
'should passthrough css variables #5',
processCss.passthrough('h1{color:rgb(255,255,var(--baz))}')
);
test(
'should passthrough css variables #6',
processCss.passthrough('h1{color:rgb(var(--foo))}')
);
test(
'should passthrough env function',
processCss.passthrough('h1{color:rgb(env(foo))}')
);
test(
'should not minify in lowercase filter properties',
processCss.passthrough(
'h1{filter:progid:DXImageTransform.Microsoft.gradient(startColorstr= #000000,endColorstr= #ffffff)}'
)
);
test(
'should not minify in uppercase filter properties',
processCss.passthrough(
'h1{FILTER:progid:DXImageTransform.Microsoft.gradient(startColorstr= #000000,endColorstr= #ffffff)}'
)
);
test.run();