aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/element.rs
diff options
context:
space:
mode:
authorMs2ger <ms2ger@gmail.com>2014-09-13 21:02:40 +0200
committerMs2ger <ms2ger@gmail.com>2014-09-13 21:02:40 +0200
commitf466d3144615bf28d4e609fdceba22cba74ae4ff (patch)
treeb046f02bea71fffbf01568a2ccceaf49a06f86a4 /components/script/dom/element.rs
parent5a90f18b7ee9a73511920acfb1e8b04c8c36372e (diff)
parentd0e095a3e5fee47d65cd5cf08cc9644223c2b64b (diff)
downloadservo-f466d3144615bf28d4e609fdceba22cba74ae4ff.tar.gz
servo-f466d3144615bf28d4e609fdceba22cba74ae4ff.zip
Merge pull request #3323 from Ms2ger/get_attribute
Stop messing with the case of the attribute name in AttributeHandlers::get_attribute; r=Manishearth
Diffstat (limited to 'components/script/dom/element.rs')
-rw-r--r--components/script/dom/element.rs17
1 files changed, 9 insertions, 8 deletions
diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs
index 30b2601f04e..2150e67f0eb 100644
--- a/components/script/dom/element.rs
+++ b/components/script/dom/element.rs
@@ -252,7 +252,10 @@ impl<'a> ElementHelpers for JSRef<'a, Element> {
}
pub trait AttributeHandlers {
- fn get_attribute(&self, namespace: Namespace, name: &str) -> Option<Temporary<Attr>>;
+ /// Returns the attribute with given namespace and case-sensitive local
+ /// name, if any.
+ fn get_attribute(&self, namespace: Namespace, local_name: &str)
+ -> Option<Temporary<Attr>>;
fn set_attribute_from_parser(&self, local_name: Atom,
value: DOMString, namespace: Namespace,
prefix: Option<DOMString>);
@@ -282,13 +285,9 @@ pub trait AttributeHandlers {
}
impl<'a> AttributeHandlers for JSRef<'a, Element> {
- fn get_attribute(&self, namespace: Namespace, name: &str) -> Option<Temporary<Attr>> {
- let element: &Element = self.deref();
- let local_name = match self.html_element_in_html_document() {
- true => Atom::from_slice(name.to_ascii_lower().as_slice()),
- false => Atom::from_slice(name)
- };
- element.attrs.borrow().iter().map(|attr| attr.root()).find(|attr| {
+ fn get_attribute(&self, namespace: Namespace, local_name: &str) -> Option<Temporary<Attr>> {
+ let local_name = Atom::from_slice(local_name);
+ self.attrs.borrow().iter().map(|attr| attr.root()).find(|attr| {
*attr.local_name() == local_name && attr.namespace == namespace
}).map(|x| Temporary::from_rooted(&*x))
}
@@ -423,6 +422,7 @@ impl<'a> AttributeHandlers for JSRef<'a, Element> {
}
fn get_url_attribute(&self, name: &str) -> DOMString {
+ assert!(name == name.to_ascii_lower().as_slice());
// XXX Resolve URL.
self.get_string_attribute(name)
}
@@ -431,6 +431,7 @@ impl<'a> AttributeHandlers for JSRef<'a, Element> {
}
fn get_string_attribute(&self, name: &str) -> DOMString {
+ assert!(name == name.to_ascii_lower().as_slice());
match self.get_attribute(Null, name) {
Some(x) => {
let x = x.root();