Add missing Element::get_elements_by_* methods

This commit is contained in:
Julien Cretin 2019-07-14 01:02:53 +02:00
parent a48a0aeb93
commit 170ce683d8
2 changed files with 25 additions and 2 deletions

View File

@ -196,4 +196,29 @@ fn element() {
request_fullscreen request_fullscreen
request_pointer_lock 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"] [Throws, Pure, BinaryName="matches"]
boolean webkitMatchesSelector(DOMString selector); boolean webkitMatchesSelector(DOMString selector);
/*TODO
[Pure] [Pure]
HTMLCollection getElementsByTagName(DOMString localName); HTMLCollection getElementsByTagName(DOMString localName);
[Throws, Pure] [Throws, Pure]
HTMLCollection getElementsByTagNameNS(DOMString? namespace, DOMString localName); HTMLCollection getElementsByTagNameNS(DOMString? namespace, DOMString localName);
[Pure] [Pure]
HTMLCollection getElementsByClassName(DOMString classNames); HTMLCollection getElementsByClassName(DOMString classNames);
*/
[ChromeOnly, Pure] [ChromeOnly, Pure]
sequence<Element> getElementsWithGrid(); sequence<Element> getElementsWithGrid();