mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Use or_else in Document.find_fragment_node.
This commit is contained in:
parent
c96018152f
commit
75ee535e3c
1 changed files with 13 additions and 16 deletions
|
@ -282,9 +282,7 @@ impl<'a> DocumentHelpers<'a> for JSRef<'a, Document> {
|
|||
/// Attempt to find a named element in this page's document.
|
||||
/// https://html.spec.whatwg.org/multipage/#the-indicated-part-of-the-document
|
||||
fn find_fragment_node(self, fragid: DOMString) -> Option<Temporary<Element>> {
|
||||
match self.GetElementById(fragid.clone()) {
|
||||
Some(node) => Some(node),
|
||||
None => {
|
||||
self.GetElementById(fragid.clone()).or_else(|| {
|
||||
let check_anchor = |&node: &JSRef<HTMLAnchorElement>| {
|
||||
let elem: JSRef<Element> = ElementCast::from_ref(node);
|
||||
elem.get_attribute(ns!(""), "name").root().map_or(false, |attr| {
|
||||
|
@ -296,8 +294,7 @@ impl<'a> DocumentHelpers<'a> for JSRef<'a, Document> {
|
|||
.filter_map(|node| HTMLAnchorElementCast::to_ref(node))
|
||||
.find(check_anchor)
|
||||
.map(|node| Temporary::from_rooted(ElementCast::from_ref(node)))
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue