- Notifications
You must be signed in to change notification settings - Fork 3.3k
/
Copy pathvariable-cssText.html
55 lines (48 loc) · 2.56 KB
/
variable-cssText.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
<!DOCTYPE html>
<html>
<head>
<title>Parse, store, and serialize CSS variable (thorugh css Text)</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/#serializing-custom-props">
<scriptsrc="/resources/testharness.js"></script>
<scriptsrc="/resources/testharnessreport.js"></script>
</head>
<body>
<divid="target1" style="--var: var1;"></div>
<divid="target2" style="margin: var(--prop);"></div>
<divid="target3" style="background: var(--prop);"></div>
<divid="target4" style="margin: var(--prop) !important;"></div>
<divid="target5" style="background: var(--prop) !important;"></div>
<divid="target6" style="background: var(--prop); background: green;"></div>
<divid="target7" style="background: green; background: var(--prop);"></div>
<divid="target8" style="color: green; color: var(--prop);"></div>
<divid="target9" style="margin: var(--prop); margin-top: 10px"></div>
<divid="target10"style="expando: var(--prop);"></div>
<divid="target11"style="color: /* comment that must not be preserved */ var(--prop) /* kept comment */ var(--prop); /* another stripped comment */ /* indeed */ "></div>
<scripttype="text/javascript">
"use strict";
vartestcases=[
{element: "target1",expectedCssText: "--var: var1;"},
{element: "target2",expectedCssText: "margin: var(--prop);"},
{element: "target3",expectedCssText: "background: var(--prop);"},
{element: "target4",expectedCssText: "margin: var(--prop) !important;"},
{element: "target5",expectedCssText: "background: var(--prop) !important;"},
{element: "target6",expectedCssText: "background: green;"},
{element: "target7",expectedCssText: "background: var(--prop);"},
{element: "target8",expectedCssText: "color: var(--prop);"},
{element: "target9",expectedCssText: "margin-right: ; margin-bottom: ; margin-left: ; margin-top: 10px;"},
{element: "target10",expectedCssText: ""},
{element: "target11",expectedCssText: "color: var(--prop) /* kept comment */ var(--prop);"}
];
testcases.forEach(function(testcase){
test(function(){
vardiv=document.getElementById(testcase.element);
varactualCssText=div.style.cssText;
assert_equals(actualCssText,testcase.expectedCssText);
},testcase.element);
});
</script>
</body>
</html>