- Notifications
You must be signed in to change notification settings - Fork 3.3k
/
Copy pathvariable-definition-keywords.html
74 lines (63 loc) · 2.96 KB
/
variable-definition-keywords.html
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
<!DOCTYPE html>
<html>
<head>
<title>CSS Variable definitions and keywords</title>
<metarel="author" title="Kevin Babbitt">
<metarel="author" title="Greg Whitworth">
<linkrel="author" title="Microsoft Corporation" href="http://microsoft.com" />
<linkrel="help" href="http://www.w3.org/TR/css-variables-1/#using-variables">
<scriptsrc="/resources/testharness.js"></script>
<scriptsrc="/resources/testharnessreport.js"></script>
<style>
/* Specify a value in a rule hitting keyword targets so that the keywords
have something to override in the cascade. */
div>div
{
--var:10px;
}
</style>
</head>
<body>
<divid="inheritParent" style="--var: 20px;">
<divid="inheritTest" style="--var: inherit;"></div>
</div>
<divid="initialParent" style="--var: 20px;">
<divid="initialTest" style="--var: initial;"></div>
</div>
<divid="unsetParent" style="--var: 20px;">
<divid="unsetTest" style="--var: unset;"></div>
</div>
<divid="revertParent" style="--var: 20px;">
<divid="revertTest" style="--var: revert;"></div>
</div>
<scripttype="text/javascript">
"use strict";
letcomputedStyle=[
{elementId: "inheritTest",property: "--var",expectedValue: "20px",testName: "computed style inherit"},
{elementId: "initialTest",property: "--var",expectedValue: "",testName: "computed style initial"},
{elementId: "unsetTest",property: "--var",expectedValue: "20px",testName: "computed style unset"},
{elementId: "revertTest",property: "--var",expectedValue: "20px",testName: "computed style revert"}
];
letspecifiedStyle=[
{elementId: "inheritTest",property: "--var",expectedValue: "inherit",testName: "specified style inherit"},
{elementId: "initialTest",property: "--var",expectedValue: "initial",testName: "specified style initial"},
{elementId: "unsetTest",property: "--var",expectedValue: "unset",testName: "specified style unset"},
{elementId: "revertTest",property: "--var",expectedValue: "revert",testName: "specified style revert"}
];
computedStyle.forEach(function(csTest){
test(function(){
varelem=document.getElementById(csTest.elementId);
varactualValue=window.getComputedStyle(elem).getPropertyValue(csTest.property).trim();
assert_equals(csTest.expectedValue,actualValue);
},csTest.testName);
});
specifiedStyle.forEach(function(ssTest){
test(function(){
varelem=document.getElementById(ssTest.elementId);
varactualValue=elem.style.getPropertyValue(ssTest.property);
assert_equals(ssTest.expectedValue,actualValue);
},ssTest.testName);
});
</script>
</body>
</html>