From 08e7cf24cd0cdb2f1c0d95718e388b7ab0f4e8ed Mon Sep 17 00:00:00 2001 From: Bruno de Oliveira Abinader Date: Fri, 12 Dec 2014 12:54:02 -0400 Subject: [PATCH] DOMTokenList::check_token_exceptions now returns an Atom --- components/script/dom/domtokenlist.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/components/script/dom/domtokenlist.rs b/components/script/dom/domtokenlist.rs index 6ba0307b14e0..4169e87487fb 100644 --- a/components/script/dom/domtokenlist.rs +++ b/components/script/dom/domtokenlist.rs @@ -5,7 +5,7 @@ use dom::attr::{Attr, AttrHelpers}; use dom::bindings::codegen::Bindings::DOMTokenListBinding; use dom::bindings::codegen::Bindings::DOMTokenListBinding::DOMTokenListMethods; -use dom::bindings::error::Fallible; +use dom::bindings::error::{ErrorResult, Fallible}; use dom::bindings::error::Error::{InvalidCharacter, Syntax}; use dom::bindings::global::GlobalRef; use dom::bindings::js::{JS, JSRef, Temporary, OptionalRootable}; @@ -48,7 +48,7 @@ impl Reflectable for DOMTokenList { trait PrivateDOMTokenListHelpers { fn attribute(self) -> Option>; - fn check_token_exceptions<'a>(self, token: &'a str) -> Fallible<&'a str>; + fn check_token_exceptions<'a>(self, token: &'a str) -> Fallible; } impl<'a> PrivateDOMTokenListHelpers for JSRef<'a, DOMTokenList> { @@ -57,11 +57,11 @@ impl<'a> PrivateDOMTokenListHelpers for JSRef<'a, DOMTokenList> { element.get_attribute(ns!(""), &self.local_name) } - fn check_token_exceptions<'a>(self, token: &'a str) -> Fallible<&'a str> { + fn check_token_exceptions<'a>(self, token: &'a str) -> Fallible { match token { "" => Err(Syntax), - token if token.find(HTML_SPACE_CHARACTERS).is_some() => Err(InvalidCharacter), - token => Ok(token) + slice if slice.find(HTML_SPACE_CHARACTERS).is_some() => Err(InvalidCharacter), + slice => Ok(Atom::from_slice(slice)) } } } @@ -90,13 +90,13 @@ impl<'a> DOMTokenListMethods for JSRef<'a, DOMTokenList> { // http://dom.spec.whatwg.org/#dom-domtokenlist-contains fn Contains(self, token: DOMString) -> Fallible { - self.check_token_exceptions(token.as_slice()).map(|slice| { + self.check_token_exceptions(token.as_slice()).map(|token| { self.attribute().root().map(|attr| { - let value = attr.value(); - let tokens = value.tokens() - .expect("Should have parsed this attribute"); - let atom = Atom::from_slice(slice); - tokens.iter().any(|token| *token == atom) + attr.value() + .tokens() + .expect("Should have parsed this attribute") + .iter() + .any(|atom| *atom == token) }).unwrap_or(false) }) }