diff options
Diffstat (limited to 'components/script/dom/attr.rs')
-rw-r--r-- | components/script/dom/attr.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/components/script/dom/attr.rs b/components/script/dom/attr.rs index 024522acfe8..856fb90aa5b 100644 --- a/components/script/dom/attr.rs +++ b/components/script/dom/attr.rs @@ -21,7 +21,8 @@ use std::mem; use std::ops::Deref; use string_cache::{Atom, Namespace}; use style::values::specified::Length; -use util::str::{DOMString, parse_unsigned_integer, split_html_space_chars, str_join}; +use util::str::{DOMString, parse_unsigned_integer, parse_legacy_color}; +use util::str::{split_html_space_chars, str_join}; #[derive(JSTraceable, PartialEq, Clone, HeapSizeOf)] pub enum AttrValue { @@ -77,6 +78,11 @@ impl AttrValue { AttrValue::Atom(value) } + pub fn from_legacy_color(string: DOMString) -> AttrValue { + let parsed = parse_legacy_color(&string).ok(); + AttrValue::Color(string, parsed) + } + /// Assumes the `AttrValue` is a `TokenList` and returns its tokens /// /// ## Panics |