diff --git a/components/script/dom/htmlcollection.rs b/components/script/dom/htmlcollection.rs index d5198b94986..f1eb1fdd706 100644 --- a/components/script/dom/htmlcollection.rs +++ b/components/script/dom/htmlcollection.rs @@ -252,11 +252,17 @@ impl HTMLCollection { let case_sensitivity = document_from_node(elem) .quirks_mode() .classes_and_ids_case_sensitivity(); + self.classes .iter() .all(|class| elem.has_class(class, case_sensitivity)) } } + + if classes.is_empty() { + return HTMLCollection::always_empty(window, root); + } + let filter = ClassNameFilter { classes: classes }; HTMLCollection::create(window, root, Box::new(filter)) } diff --git a/tests/wpt/metadata/dom/nodes/getElementsByClassName-empty-set.html.ini b/tests/wpt/metadata/dom/nodes/getElementsByClassName-empty-set.html.ini deleted file mode 100644 index 88cb5872361..00000000000 --- a/tests/wpt/metadata/dom/nodes/getElementsByClassName-empty-set.html.ini +++ /dev/null @@ -1,10 +0,0 @@ -[getElementsByClassName-empty-set.html] - [Passing a space to getElementsByClassName should return an empty HTMLCollection] - expected: FAIL - - [Passing three spaces to getElementsByClassName should return an empty HTMLCollection] - expected: FAIL - - [Passing an empty string to getElementsByClassName should return an empty HTMLCollection] - expected: FAIL -