aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/script/dom/htmlcollection.rs
diff options
context:
space:
mode:
authorTom Schuster <evilpies@gmail.com>2014-04-19 22:23:13 +0200
committerTom Schuster <evilpies@gmail.com>2014-04-22 22:19:52 +0200
commit4c057deaf9e90aa4e27056d331419611384e8427 (patch)
tree0398a6961328ce29616ef6f12e8b30b724a49557 /src/components/script/dom/htmlcollection.rs
parente332f2f0fec23b2318589b08c2a1e8fb1557e672 (diff)
downloadservo-4c057deaf9e90aa4e27056d331419611384e8427.tar.gz
servo-4c057deaf9e90aa4e27056d331419611384e8427.zip
Implement ParentNode.children for Document and Element
Also implement it for DocumentFragment
Diffstat (limited to 'src/components/script/dom/htmlcollection.rs')
-rw-r--r--src/components/script/dom/htmlcollection.rs12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/components/script/dom/htmlcollection.rs b/src/components/script/dom/htmlcollection.rs
index e88aedd02db..95637f9db1a 100644
--- a/src/components/script/dom/htmlcollection.rs
+++ b/src/components/script/dom/htmlcollection.rs
@@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-use dom::bindings::codegen::InheritTypes::{ElementCast};
+use dom::bindings::codegen::InheritTypes::{ElementCast, NodeCast};
use dom::bindings::codegen::HTMLCollectionBinding;
use dom::bindings::js::JS;
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
@@ -104,6 +104,16 @@ impl HTMLCollection {
};
HTMLCollection::create(window, root, ~filter)
}
+
+ pub fn children(window: &JS<Window>, root: &JS<Node>) -> JS<HTMLCollection> {
+ struct ElementChildFilter;
+ impl CollectionFilter for ElementChildFilter {
+ fn filter(&self, elem: &JS<Element>, root: &JS<Node>) -> bool {
+ root.is_parent_of(&NodeCast::from(elem))
+ }
+ }
+ HTMLCollection::create(window, root, ~ElementChildFilter)
+ }
}
impl HTMLCollection {