aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/nodelist.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/dom/nodelist.rs')
-rw-r--r--components/script/dom/nodelist.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/components/script/dom/nodelist.rs b/components/script/dom/nodelist.rs
index 3810f16b22c..391d21d5865 100644
--- a/components/script/dom/nodelist.rs
+++ b/components/script/dom/nodelist.rs
@@ -97,6 +97,13 @@ impl NodeList {
panic!("called as_simple_list() on a children node list")
}
}
+
+ pub fn iter(&self) -> NodeListIterator {
+ NodeListIterator {
+ nodes: self,
+ offset: 0,
+ }
+ }
}
#[derive(JSTraceable, HeapSizeOf)]
@@ -277,3 +284,18 @@ impl ChildrenList {
self.last_index.set(0u32);
}
}
+
+pub struct NodeListIterator<'a> {
+ nodes: &'a NodeList,
+ offset: u32,
+}
+
+impl<'a> Iterator for NodeListIterator<'a> {
+ type Item = Root<Node>;
+
+ fn next(&mut self) -> Option<Root<Node>> {
+ let result = self.nodes.Item(self.offset);
+ self.offset = self.offset + 1;
+ result
+ }
+}