blob: e6bdd4fffea6359e8c5b6c73a0d4de97696fec2e [file] [log] [blame]
<!doctype html>
<meta charset="utf-8">
<title>Declared StylePropertyMap.clear</title>
<link rel="help" href="https://drafts.css-houdini.org/css-typed-om-1/#dom-stylepropertymap-clear">
<meta name="assert" content="Test declared StylePropertyMap.clear" />
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../../resources/testhelper.js"></script>
<body>
<div id="log"></div>
<script>
'use strict';
test(t => {
let styleMap = createInlineStyleMap(t, '');
styleMap.clear();
assert_array_equals([...styleMap], []);
}, 'Clearing an empty CSS rule is a no-op');
test(t => {
let styleMap = createInlineStyleMap(t, '--foo: auto; width: 10px; transition-duration: 1s, 2s');
styleMap.clear();
assert_equals(styleMap.get('--foo'), null,
'Custom properties should be cleared');
assert_equals(styleMap.get('width'), null,
'CSS properties should be cleared');
assert_equals(styleMap.get('transition-duration'), null,
'List-valued properties should be cleared');
assert_array_equals([...styleMap], []);
}, 'Can clear a CSS rule containing properties');
test(t => {
let [rule, styleMap] = createRuleWithDeclaredStyleMap(t, 'width: 10px;');
styleMap.clear();
assert_equals(rule.style.width, '', 'CSS rule style should be cleared');
}, 'Declared StylePropertyMap.clear updates the CSS rule');
</script>