Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /dom/nodes/getElementsByClassName-empty-set.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<title>Node.prototype.getElementsByClassName with no real class names</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<span class=" ">test</span>
<script>
"use strict";
test(() => {
const elements = document.getElementsByClassName("");
assert_array_equals(elements, []);
}, "Passing an empty string to getElementsByClassName should return an empty HTMLCollection");
test(() => {
const elements = document.getElementsByClassName(" ");
assert_array_equals(elements, []);
}, "Passing a space to getElementsByClassName should return an empty HTMLCollection");
test(() => {
const elements = document.getElementsByClassName(" ");
assert_array_equals(elements, []);
}, "Passing three spaces to getElementsByClassName should return an empty HTMLCollection");
</script>