summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/dom/nodes/getElementsByClassName-empty-set.html
blob: 75b8d5a9f8c16da0ad12da7bff2139d87060c054 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<title>Node.prototype.getElementsByClassName with no real class names</title>
<link rel=help href="https://dom.spec.whatwg.org/#dom-document-getelementsbyclassname">
<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>