mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
find_node_by_unique_id should use find
find_node_by_unique_id should use find instead of for-loop
This commit is contained in:
parent
83b2388ef4
commit
cad3115708
1 changed files with 1 additions and 9 deletions
|
@ -40,15 +40,7 @@ use util::str::DOMString;
|
||||||
fn find_node_by_unique_id(page: &Rc<Page>, pipeline: PipelineId, node_id: String) -> Option<Root<Node>> {
|
fn find_node_by_unique_id(page: &Rc<Page>, pipeline: PipelineId, node_id: String) -> Option<Root<Node>> {
|
||||||
let page = get_page(&*page, pipeline);
|
let page = get_page(&*page, pipeline);
|
||||||
let document = page.document();
|
let document = page.document();
|
||||||
let node = document.upcast::<Node>();
|
document.upcast::<Node>().traverse_preorder().find(|candidate| candidate.get_unique_id() == node_id)
|
||||||
|
|
||||||
for candidate in node.traverse_preorder() {
|
|
||||||
if candidate.get_unique_id() == node_id {
|
|
||||||
return Some(candidate);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
None
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue