diff options
Diffstat (limited to 'components/script/dom')
-rw-r--r-- | components/script/dom/element.rs | 8 | ||||
-rw-r--r-- | components/script/dom/htmlimageelement.rs | 5 | ||||
-rw-r--r-- | components/script/dom/virtualmethods.rs | 4 |
3 files changed, 10 insertions, 7 deletions
diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs index a81c515aef8..ca1ac321b57 100644 --- a/components/script/dom/element.rs +++ b/components/script/dom/element.rs @@ -509,7 +509,7 @@ impl<'a> AttributeHandlers for JSRef<'a, Element> { value: DOMString) -> AttrValue { if *namespace == ns!("") { vtable_for(&NodeCast::from_ref(self)) - .parse_plain_attribute(local_name.as_slice(), value) + .parse_plain_attribute(local_name, value) } else { StringAttrValue(value) } @@ -1037,10 +1037,10 @@ impl<'a> VirtualMethods for JSRef<'a, Element> { self.notify_content_changed(); } - fn parse_plain_attribute(&self, name: &str, value: DOMString) -> AttrValue { + fn parse_plain_attribute(&self, name: &Atom, value: DOMString) -> AttrValue { match name { - "id" => AttrValue::from_atomic(value), - "class" => AttrValue::from_tokenlist(value), + &atom!("id") => AttrValue::from_atomic(value), + &atom!("class") => AttrValue::from_tokenlist(value), _ => self.super_type().unwrap().parse_plain_attribute(name, value), } } diff --git a/components/script/dom/htmlimageelement.rs b/components/script/dom/htmlimageelement.rs index 635839805c3..3cdd4a4eaee 100644 --- a/components/script/dom/htmlimageelement.rs +++ b/components/script/dom/htmlimageelement.rs @@ -195,9 +195,10 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLImageElement> { } } - fn parse_plain_attribute(&self, name: &str, value: DOMString) -> AttrValue { + fn parse_plain_attribute(&self, name: &Atom, value: DOMString) -> AttrValue { match name { - "width" | "height" | "hspace" | "vspace" => AttrValue::from_u32(value, 0), + &atom!("width") | &atom!("height") | + &atom!("hspace") | &atom!("vspace") => AttrValue::from_u32(value, 0), _ => self.super_type().unwrap().parse_plain_attribute(name, value), } } diff --git a/components/script/dom/virtualmethods.rs b/components/script/dom/virtualmethods.rs index 0b23ffc37ea..03c4b27c737 100644 --- a/components/script/dom/virtualmethods.rs +++ b/components/script/dom/virtualmethods.rs @@ -68,6 +68,8 @@ use dom::node::{Node, NodeHelpers, ElementNodeTypeId, CloneChildrenFlag}; use servo_util::str::DOMString; +use string_cache::Atom; + /// Trait to allow DOM nodes to opt-in to overriding (or adding to) common /// behaviours. Replicates the effect of C++ virtual methods. pub trait VirtualMethods { @@ -95,7 +97,7 @@ pub trait VirtualMethods { /// Returns the right AttrValue variant for the attribute with name `name` /// on this element. - fn parse_plain_attribute(&self, name: &str, value: DOMString) -> AttrValue { + fn parse_plain_attribute(&self, name: &Atom, value: DOMString) -> AttrValue { match self.super_type() { Some(ref s) => s.parse_plain_attribute(name, value), _ => StringAttrValue(value), |