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-attr-stray-braces.tentative.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<meta charset="utf-8">
<title>CSSOM: Stray braces in style attribute and cssText</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="target"></div>
<script>
const TESTS = [
["}color: red", ""],
["} color: red; z-index: 1", "z-index: 1;"],
["}; z-index: 1", "z-index: 1;"],
["z-index: 1; }color: red", "z-index: 1;"],
["z-index: 1; }", "z-index: 1;"],
["{}color: red", ""],
["{}color: red; z-index: 1", "z-index: 1;"],
["@foo{}z-index: 1", "z-index: 1;"],
];
const target = document.getElementById("target");
for (const [input, expected] of TESTS) {
test(() => {
target.setAttribute("style", input);
assert_equals(target.style.cssText, expected);
}, `style attribute: ${input}`);
test(() => {
target.removeAttribute("style");
target.style.cssText = input;
assert_equals(target.style.cssText, expected);
}, `cssText setter: ${input}`);
}
</script>