-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
css_table.go
72 lines (63 loc) · 1.88 KB
/
css_table.go
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
package compat
type CSSFeature uint32
const (
HexRGBA CSSFeature = 1 << iota
RebeccaPurple
// This feature includes all of the following:
// - Allow floats in rgb() and rgba()
// - hsl() can accept alpha values
// - rgb() can accept alpha values
// - Space-separated functional color notations
Modern_RGB_HSL
InsetProperty
)
func (features CSSFeature) Has(feature CSSFeature) bool {
return (features & feature) != 0
}
var cssTable = map[CSSFeature]map[Engine][]versionRange{
// Data from: https://developer.mozilla.org/en-US/docs/Web/CSS/color_value
HexRGBA: {
Chrome: {{start: v{62, 0, 0}}},
Edge: {{start: v{79, 0, 0}}},
Firefox: {{start: v{49, 0, 0}}},
IOS: {{start: v{9, 3, 0}}},
Safari: {{start: v{9, 1, 0}}},
},
RebeccaPurple: {
Chrome: {{start: v{38, 0, 0}}},
Edge: {{start: v{12, 0, 0}}},
Firefox: {{start: v{33, 0, 0}}},
IOS: {{start: v{8, 0, 0}}},
Safari: {{start: v{9, 0, 0}}},
},
Modern_RGB_HSL: {
Chrome: {{start: v{66, 0, 0}}},
Edge: {{start: v{79, 0, 0}}},
Firefox: {{start: v{52, 0, 0}}},
IOS: {{start: v{12, 2, 0}}},
Safari: {{start: v{12, 1, 0}}},
},
// Data from: https://developer.mozilla.org/en-US/docs/Web/CSS/inset
InsetProperty: {
Chrome: {{start: v{87, 0, 0}}},
Edge: {{start: v{87, 0, 0}}},
Firefox: {{start: v{66, 0, 0}}},
IOS: {{start: v{14, 5, 0}}},
Safari: {{start: v{14, 1, 0}}},
},
}
// Return all features that are not available in at least one environment
func UnsupportedCSSFeatures(constraints map[Engine][]int) (unsupported CSSFeature) {
for feature, engines := range cssTable {
for engine, version := range constraints {
if engine == ES || engine == Node {
// Specifying "--target=es2020" shouldn't affect CSS
continue
}
if versionRanges, ok := engines[engine]; !ok || !isVersionSupported(versionRanges, version) {
unsupported |= feature
}
}
}
return
}