Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /css/cssom/style-set-custom-property.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<meta charset="utf-8">
<title>Setting value for custom property</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="div" class="div"></div>
<script>
"use strict";
test(() => {
const div = document.getElementById("div");
div.style.setProperty("--x", 0);
div.style.setProperty("--x", 1);
assert_equals(div.style.getPropertyValue("--x"), "1", 'Property value is "1"');
assert_equals(div.style.length, 1, "style.length is 1");
assert_equals(div.style.item(0), "--x", 'style.item(0) is "--x"');
assert_equals(div.style.item(1), "", "style.item(1) is empty string");
});
</script>