diff options
Diffstat (limited to 'components/script/dom/attr.rs')
-rw-r--r-- | components/script/dom/attr.rs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/components/script/dom/attr.rs b/components/script/dom/attr.rs index 1820a854cd8..536600e5f34 100644 --- a/components/script/dom/attr.rs +++ b/components/script/dom/attr.rs @@ -23,6 +23,7 @@ use string_cache::{Atom, Namespace}; use std::borrow::ToOwned; use std::cell::Ref; use std::mem; +use std::ops::Deref; pub enum AttrSettingType { FirstSetAttr, @@ -79,8 +80,10 @@ impl AttrValue { } } -impl Str for AttrValue { - fn as_slice<'a>(&'a self) -> &'a str { +impl Deref for AttrValue { + type Target = str; + + fn deref<'a>(&'a self) -> &'a str { match *self { AttrValue::String(ref value) | AttrValue::TokenList(ref value, _) | @@ -151,7 +154,7 @@ impl<'a> AttrMethods for JSRef<'a, Attr> { // https://dom.spec.whatwg.org/#dom-attr-value fn Value(self) -> DOMString { - self.value().as_slice().to_owned() + (**self.value()).to_owned() } // https://dom.spec.whatwg.org/#dom-attr-value @@ -299,7 +302,7 @@ impl AttrHelpersForLayout for Attr { unsafe fn value_ref_forever(&self) -> &'static str { // This transmute is used to cheat the lifetime restriction. let value = mem::transmute::<&AttrValue, &AttrValue>(self.value.borrow_for_layout()); - value.as_slice() + &**value } #[inline] |