Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /css/selectors/class-selector-change.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<title>Changing classList updates result of Element.matches()</title>
<script src='/resources/testharness.js'></script>
<script src='/resources/testharnessreport.js'></script>
<script>
"use strict";
test(() => {
const div = document.createElement("div");
assert_equals(div.matches(".foo"), false, "initial");
div.classList.add("foo");
assert_equals(div.matches(".foo"), true, "class added");
div.classList.remove("foo");
assert_equals(div.matches(".foo"), false, "class removed");
}, "toggle class sync");
</script>