mirror of
https://github.com/servo/servo.git
synced 2025-06-23 16:44:33 +01:00
Clean up AttributeHandlers::get_attribute() for JSRef.
This commit is contained in:
parent
7f2d551e47
commit
b22f6e1f81
1 changed files with 12 additions and 9 deletions
|
@ -229,15 +229,18 @@ pub trait AttributeHandlers {
|
||||||
|
|
||||||
impl<'a> AttributeHandlers for JSRef<'a, Element> {
|
impl<'a> AttributeHandlers for JSRef<'a, Element> {
|
||||||
fn get_attribute(&self, namespace: Namespace, name: &str) -> Option<Temporary<Attr>> {
|
fn get_attribute(&self, namespace: Namespace, name: &str) -> Option<Temporary<Attr>> {
|
||||||
if self.html_element_in_html_document() {
|
let element: &Element = self.deref();
|
||||||
self.deref().attrs.iter().map(|attr| attr.root()).find(|attr| {
|
let is_html_element = self.html_element_in_html_document();
|
||||||
name.to_ascii_lower() == attr.local_name && attr.namespace == namespace
|
|
||||||
}).map(|x| Temporary::from_rooted(&*x))
|
element.attrs.iter().map(|attr| attr.root()).find(|attr| {
|
||||||
} else {
|
let same_name = if is_html_element {
|
||||||
self.deref().attrs.iter().map(|attr| attr.root()).find(|attr| {
|
name.to_ascii_lower() == attr.local_name
|
||||||
name == attr.local_name && attr.namespace == namespace
|
} else {
|
||||||
}).map(|x| Temporary::from_rooted(&*x))
|
name == attr.local_name
|
||||||
}
|
};
|
||||||
|
|
||||||
|
same_name && attr.namespace == namespace
|
||||||
|
}).map(|x| Temporary::from_rooted(&*x))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_attribute_from_parser(&mut self, local_name: DOMString,
|
fn set_attribute_from_parser(&mut self, local_name: DOMString,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue