Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /dom/nodes/Element-closest-null-selectors.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<title>element.closest() with #null and .null selectors</title>
<meta charset="utf-8">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<p id="testP">Some text</p>
<script>
"use strict";
test(() => {
const p = document.getElementById("testP");
assert_equals(p.closest("#null"), null);
}, "element.closest('#null') should return null");
test(() => {
const p = document.getElementById("testP");
assert_equals(p.closest(".null"), null);
}, "element.closest('.null') should return null");
</script>