From 170ce683d865284d67cea10f971c0a652377ccec Mon Sep 17 00:00:00 2001 From: Julien Cretin Date: Sun, 14 Jul 2019 01:02:53 +0200 Subject: [PATCH] Add missing Element::get_elements_by_* methods --- crates/web-sys/tests/wasm/element.rs | 25 +++++++++++++++++++ crates/web-sys/webidls/enabled/Element.webidl | 2 -- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/crates/web-sys/tests/wasm/element.rs b/crates/web-sys/tests/wasm/element.rs index cb01a78071b..0092c41f811 100644 --- a/crates/web-sys/tests/wasm/element.rs +++ b/crates/web-sys/tests/wasm/element.rs @@ -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(); } diff --git a/crates/web-sys/webidls/enabled/Element.webidl b/crates/web-sys/webidls/enabled/Element.webidl index 9fdf508c610..c012b13762a 100644 --- a/crates/web-sys/webidls/enabled/Element.webidl +++ b/crates/web-sys/webidls/enabled/Element.webidl @@ -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 getElementsWithGrid();