renaming tokens(), atom() and uint() and rewriting to return or panic

This commit is contained in:
Prabhjyot Singh Sodhi 2015-09-02 14:44:39 +05:30
parent eaf90c0b1c
commit 105ea0d690
8 changed files with 31 additions and 35 deletions

View file

@ -61,7 +61,7 @@ impl DOMTokenListMethods for DOMTokenList {
fn Length(&self) -> u32 {
self.attribute().map(|attr| {
let attr = attr.r();
attr.value().tokens().map(|tokens| tokens.len()).unwrap_or(0)
attr.value().as_tokens().len()
}).unwrap_or(0) as u32
}
@ -69,7 +69,7 @@ impl DOMTokenListMethods for DOMTokenList {
fn Item(&self, index: u32) -> Option<DOMString> {
self.attribute().and_then(|attr| {
let attr = attr.r();
attr.value().tokens().and_then(|tokens| {
Some(attr.value().as_tokens()).and_then(|tokens| {
tokens.get(index as usize).map(|token| (**token).to_owned())
})
})
@ -81,10 +81,9 @@ impl DOMTokenListMethods for DOMTokenList {
self.attribute().map(|attr| {
let attr = attr.r();
attr.value()
.tokens()
.expect("Should have parsed this attribute")
.as_tokens()
.iter()
.any(|atom| *atom == token)
.any(|atom: &Atom| *atom == token)
}).unwrap_or(false)
})
}