Merge pull request #1665 from ia0/getElementsByClassName

Add Element::get_elements_by_class_name
This commit is contained in:
Alex Crichton 2019-07-15 12:57:18 -05:00 committed by GitHub
commit 1807de74a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 2 deletions

View File

@ -196,4 +196,29 @@ fn element() {
request_fullscreen
request_pointer_lock
*/
let child = new_div();
assert_eq!(
element.get_elements_by_tag_name("div").length(),
0,
"Element should not contain any div child"
);
element.append_child(&child).unwrap();
assert_eq!(
element.get_elements_by_tag_name("div").length(),
1,
"Element should contain one div child"
);
assert_eq!(
element.get_elements_by_class_name("foo").length(),
0,
"Element should not have childs with class foo"
);
child.class_list().add_1("foo").unwrap();
assert_eq!(
element.get_elements_by_class_name("foo").length(),
1,
"Element should have one child with class foo"
);
element.remove_child(&child).unwrap();
}

View File

@ -65,14 +65,12 @@ interface Element : Node {
[Throws, Pure, BinaryName="matches"]
boolean webkitMatchesSelector(DOMString selector);
/*TODO
[Pure]
HTMLCollection getElementsByTagName(DOMString localName);
[Throws, Pure]
HTMLCollection getElementsByTagNameNS(DOMString? namespace, DOMString localName);
[Pure]
HTMLCollection getElementsByClassName(DOMString classNames);
*/
[ChromeOnly, Pure]
sequence<Element> getElementsWithGrid();