diff options
Diffstat (limited to 'components/script/dom/element.rs')
-rw-r--r-- | components/script/dom/element.rs | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs index 0ca6a0e7e2e..57a18db3056 100644 --- a/components/script/dom/element.rs +++ b/components/script/dom/element.rs @@ -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 |