diff options
Diffstat (limited to 'components/script/dom/domtokenlist.rs')
-rw-r--r-- | components/script/dom/domtokenlist.rs | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/components/script/dom/domtokenlist.rs b/components/script/dom/domtokenlist.rs index 8edf6f18c3c..c681dc7d710 100644 --- a/components/script/dom/domtokenlist.rs +++ b/components/script/dom/domtokenlist.rs @@ -35,7 +35,7 @@ impl DOMTokenList { pub fn new(element: JSRef<Element>, local_name: &Atom) -> Temporary<DOMTokenList> { let window = window_from_node(element).root(); reflect_dom_object(box DOMTokenList::new_inherited(element, local_name.clone()), - GlobalRef::Window(*window), + GlobalRef::Window(window.r()), DOMTokenListBinding::Wrap) } } @@ -48,7 +48,7 @@ trait PrivateDOMTokenListHelpers { impl<'a> PrivateDOMTokenListHelpers for JSRef<'a, DOMTokenList> { fn attribute(self) -> Option<Temporary<Attr>> { let element = self.element.root(); - element.get_attribute(ns!(""), &self.local_name) + element.r().get_attribute(ns!(""), &self.local_name) } fn check_token_exceptions<'a>(self, token: &'a str) -> Fallible<Atom> { @@ -65,13 +65,13 @@ impl<'a> DOMTokenListMethods for JSRef<'a, DOMTokenList> { // http://dom.spec.whatwg.org/#dom-domtokenlist-length fn Length(self) -> u32 { self.attribute().root().map(|attr| { - attr.value().tokens().map(|tokens| tokens.len()).unwrap_or(0) + attr.r().value().tokens().map(|tokens| tokens.len()).unwrap_or(0) }).unwrap_or(0) as u32 } // http://dom.spec.whatwg.org/#dom-domtokenlist-item fn Item(self, index: u32) -> Option<DOMString> { - self.attribute().root().and_then(|attr| attr.value().tokens().and_then(|tokens| { + self.attribute().root().and_then(|attr| attr.r().value().tokens().and_then(|tokens| { tokens.get(index as uint).map(|token| token.as_slice().into_string()) })) } @@ -86,7 +86,8 @@ impl<'a> DOMTokenListMethods for JSRef<'a, DOMTokenList> { fn Contains(self, token: DOMString) -> Fallible<bool> { self.check_token_exceptions(token.as_slice()).map(|token| { self.attribute().root().map(|attr| { - attr.value() + attr.r() + .value() .tokens() .expect("Should have parsed this attribute") .iter() @@ -98,42 +99,42 @@ impl<'a> DOMTokenListMethods for JSRef<'a, DOMTokenList> { // https://dom.spec.whatwg.org/#dom-domtokenlist-add fn Add(self, tokens: Vec<DOMString>) -> ErrorResult { let element = self.element.root(); - let mut atoms = element.get_tokenlist_attribute(&self.local_name); + let mut atoms = element.r().get_tokenlist_attribute(&self.local_name); for token in tokens.iter() { let token = try!(self.check_token_exceptions(token.as_slice())); if !atoms.iter().any(|atom| *atom == token) { atoms.push(token); } } - element.set_atomic_tokenlist_attribute(&self.local_name, atoms); + element.r().set_atomic_tokenlist_attribute(&self.local_name, atoms); Ok(()) } // https://dom.spec.whatwg.org/#dom-domtokenlist-remove fn Remove(self, tokens: Vec<DOMString>) -> ErrorResult { let element = self.element.root(); - let mut atoms = element.get_tokenlist_attribute(&self.local_name); + let mut atoms = element.r().get_tokenlist_attribute(&self.local_name); for token in tokens.iter() { let token = try!(self.check_token_exceptions(token.as_slice())); atoms.iter().position(|atom| *atom == token).and_then(|index| { atoms.remove(index) }); } - element.set_atomic_tokenlist_attribute(&self.local_name, atoms); + element.r().set_atomic_tokenlist_attribute(&self.local_name, atoms); Ok(()) } // https://dom.spec.whatwg.org/#dom-domtokenlist-toggle fn Toggle(self, token: DOMString, force: Option<bool>) -> Fallible<bool> { let element = self.element.root(); - let mut atoms = element.get_tokenlist_attribute(&self.local_name); + let mut atoms = element.r().get_tokenlist_attribute(&self.local_name); let token = try!(self.check_token_exceptions(token.as_slice())); match atoms.iter().position(|atom| *atom == token) { Some(index) => match force { Some(true) => Ok(true), _ => { atoms.remove(index); - element.set_atomic_tokenlist_attribute(&self.local_name, atoms); + element.r().set_atomic_tokenlist_attribute(&self.local_name, atoms); Ok(false) } }, @@ -141,7 +142,7 @@ impl<'a> DOMTokenListMethods for JSRef<'a, DOMTokenList> { Some(false) => Ok(false), _ => { atoms.push(token); - element.set_atomic_tokenlist_attribute(&self.local_name, atoms); + element.r().set_atomic_tokenlist_attribute(&self.local_name, atoms); Ok(true) } } |