mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Use try syntax for Option where appropriate
This commit is contained in:
parent
fe16c1d5c3
commit
2d45e9d2da
19 changed files with 65 additions and 180 deletions
|
@ -1039,24 +1039,20 @@ impl Element {
|
|||
// https://dom.spec.whatwg.org/#locate-a-namespace-prefix
|
||||
pub fn lookup_prefix(&self, namespace: Namespace) -> Option<DOMString> {
|
||||
for node in self.upcast::<Node>().inclusive_ancestors() {
|
||||
match node.downcast::<Element>() {
|
||||
Some(element) => {
|
||||
// Step 1.
|
||||
if *element.namespace() == namespace {
|
||||
if let Some(prefix) = element.GetPrefix() {
|
||||
return Some(prefix);
|
||||
}
|
||||
}
|
||||
let element = node.downcast::<Element>()?;
|
||||
// Step 1.
|
||||
if *element.namespace() == namespace {
|
||||
if let Some(prefix) = element.GetPrefix() {
|
||||
return Some(prefix);
|
||||
}
|
||||
}
|
||||
|
||||
// Step 2.
|
||||
for attr in element.attrs.borrow().iter() {
|
||||
if attr.prefix() == Some(&namespace_prefix!("xmlns")) &&
|
||||
**attr.value() == *namespace {
|
||||
return Some(attr.LocalName());
|
||||
}
|
||||
}
|
||||
},
|
||||
None => return None,
|
||||
// Step 2.
|
||||
for attr in element.attrs.borrow().iter() {
|
||||
if attr.prefix() == Some(&namespace_prefix!("xmlns")) &&
|
||||
**attr.value() == *namespace {
|
||||
return Some(attr.LocalName());
|
||||
}
|
||||
}
|
||||
}
|
||||
None
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue