Skip to content

Commit

Permalink
Add missing Element::get_elements_by_* methods
Browse files Browse the repository at this point in the history
  • Loading branch information
ia0 committed Jul 15, 2019
1 parent a48a0ae commit 170ce68
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
25 changes: 25 additions & 0 deletions crates/web-sys/tests/wasm/element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
2 changes: 0 additions & 2 deletions crates/web-sys/webidls/enabled/Element.webidl
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down

0 comments on commit 170ce68

Please sign in to comment.