Implement ParentNode.children for Document and Element

Also implement it for DocumentFragment
This commit is contained in:
Tom Schuster 2014-04-19 22:23:13 +02:00
parent e332f2f0fe
commit 4c057deaf9
9 changed files with 67 additions and 5 deletions

View file

@ -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 {