mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Implement ParentNode.children for Document and Element
Also implement it for DocumentFragment
This commit is contained in:
parent
e332f2f0fe
commit
4c057deaf9
9 changed files with 67 additions and 5 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue