Skip to content

Commit

Permalink
Merge pull request #1665 from ia0/getElementsByClassName
Browse files Browse the repository at this point in the history
Add Element::get_elements_by_class_name
  • Loading branch information
alexcrichton authored Jul 15, 2019
2 parents a48a0ae + 170ce68 commit 1807de7
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 1807de7

Please sign in to comment.