mirror of
https://github.com/servo/servo.git
synced 2025-08-02 12:10:29 +01:00
Auto merge of #29646 - CYBAI:fix-classname-filter, r=jdm
Fix checking for empty set in getElementsByClassName Because empty set with `.all(predicate)` will always return `true`, it will result in always filtering wrong elements when the classes is empty set. Thus, we return earlier with `always_empty` HTMLCollection in the empty classes case so that we can avoid filtering on empty sets. With adding the checking, we can fix the failures in `/dom/nodes/getElementsByClassName-empty-set.html`. --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [ ] These changes fix #___ (GitHub issue number if applicable) - [x] There are tests for these changes
This commit is contained in:
commit
c44c6e8c11
2 changed files with 6 additions and 10 deletions
|
@ -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))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue