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,16 +229,19 @@ pub trait AttributeHandlers {
|
|||
|
||||
impl<'a> AttributeHandlers for JSRef<'a, Element> {
|
||||
fn get_attribute(&self, namespace: Namespace, name: &str) -> Option<Temporary<Attr>> {
|
||||
if self.html_element_in_html_document() {
|
||||
self.deref().attrs.iter().map(|attr| attr.root()).find(|attr| {
|
||||
name.to_ascii_lower() == attr.local_name && attr.namespace == namespace
|
||||
}).map(|x| Temporary::from_rooted(&*x))
|
||||
let element: &Element = self.deref();
|
||||
let is_html_element = self.html_element_in_html_document();
|
||||
|
||||
element.attrs.iter().map(|attr| attr.root()).find(|attr| {
|
||||
let same_name = if is_html_element {
|
||||
name.to_ascii_lower() == attr.local_name
|
||||
} else {
|
||||
self.deref().attrs.iter().map(|attr| attr.root()).find(|attr| {
|
||||
name == attr.local_name && attr.namespace == namespace
|
||||
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,
|
||||
value: DOMString, namespace: Namespace,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue