mirror of
https://github.com/servo/servo.git
synced 2025-06-25 09:34:32 +01:00
Make simple NodeLists use Vec.
This commit is contained in:
parent
a1ec0cec11
commit
674fd893cb
2 changed files with 4 additions and 4 deletions
|
@ -608,7 +608,7 @@ impl Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn createNodeList(&self, callback: |node: &JS<Node>| -> bool) -> JS<NodeList> {
|
pub fn createNodeList(&self, callback: |node: &JS<Node>| -> bool) -> JS<NodeList> {
|
||||||
let mut nodes: ~[JS<Node>] = ~[];
|
let mut nodes = vec!();
|
||||||
match self.GetDocumentElement() {
|
match self.GetDocumentElement() {
|
||||||
None => {},
|
None => {},
|
||||||
Some(root) => {
|
Some(root) => {
|
||||||
|
|
|
@ -10,7 +10,7 @@ use dom::window::Window;
|
||||||
|
|
||||||
#[deriving(Encodable)]
|
#[deriving(Encodable)]
|
||||||
pub enum NodeListType {
|
pub enum NodeListType {
|
||||||
Simple(~[JS<Node>]),
|
Simple(Vec<JS<Node>>),
|
||||||
Children(JS<Node>)
|
Children(JS<Node>)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ impl NodeList {
|
||||||
window, NodeListBinding::Wrap)
|
window, NodeListBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_simple_list(window: &JS<Window>, elements: ~[JS<Node>]) -> JS<NodeList> {
|
pub fn new_simple_list(window: &JS<Window>, elements: Vec<JS<Node>>) -> JS<NodeList> {
|
||||||
NodeList::new(window, Simple(elements))
|
NodeList::new(window, Simple(elements))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ impl NodeList {
|
||||||
pub fn Item(&self, index: u32) -> Option<JS<Node>> {
|
pub fn Item(&self, index: u32) -> Option<JS<Node>> {
|
||||||
match self.list_type {
|
match self.list_type {
|
||||||
_ if index >= self.Length() => None,
|
_ if index >= self.Length() => None,
|
||||||
Simple(ref elems) => Some(elems[index as uint].clone()),
|
Simple(ref elems) => Some(elems.get(index as uint).clone()),
|
||||||
Children(ref node) => node.children().nth(index as uint)
|
Children(ref node) => node.children().nth(index as uint)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue