Added AttrValue::from_atomic_tokens & Element::set_atomic_tokenlist_attribute

This commit is contained in:
Bruno de Oliveira Abinader 2014-12-20 16:56:19 -04:00
parent c5f7e553e4
commit 8859286a99
2 changed files with 14 additions and 0 deletions

View file

@ -47,6 +47,14 @@ impl AttrValue {
AttrValue::TokenList(tokens, atoms)
}
pub fn from_atomic_tokens(atoms: Vec<Atom>) -> AttrValue {
let tokens = {
let slices: Vec<&str> = atoms.iter().map(|atom| atom.as_slice()).collect();
slices.connect("\x20")
};
AttrValue::TokenList(tokens, atoms)
}
pub fn from_u32(string: DOMString, default: u32) -> AttrValue {
let result: u32 = from_str(string.as_slice()).unwrap_or(default);
AttrValue::UInt(string, result)