mirror of
https://github.com/servo/servo.git
synced 2025-08-04 05:00:08 +01:00
Cleanup, refactor FormDataMethods::Get
This commit is contained in:
parent
2ca48ca404
commit
b0d2194a4a
1 changed files with 6 additions and 13 deletions
|
@ -85,21 +85,14 @@ impl FormDataMethods for FormData {
|
||||||
self.data.borrow_mut().remove(&name);
|
self.data.borrow_mut().remove(&name);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unsafe_code)]
|
|
||||||
// https://xhr.spec.whatwg.org/#dom-formdata-get
|
// https://xhr.spec.whatwg.org/#dom-formdata-get
|
||||||
fn Get(&self, name: DOMString) -> Option<FileOrString> {
|
fn Get(&self, name: DOMString) -> Option<FileOrString> {
|
||||||
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
self.data.borrow()
|
||||||
let data = self.data.borrow();
|
.get(&name)
|
||||||
if data.contains_key(&name) {
|
.map(|entry| match entry[0] {
|
||||||
match data[&name][0].clone() {
|
FormDatum::StringData(ref s) => eString(s.clone()),
|
||||||
FormDatum::StringData(ref s) => Some(eString(s.clone())),
|
FormDatum::FileData(ref f) => eFile(f.root()),
|
||||||
FormDatum::FileData(ref f) => {
|
})
|
||||||
Some(eFile(f.root()))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://xhr.spec.whatwg.org/#dom-formdata-has
|
// https://xhr.spec.whatwg.org/#dom-formdata-has
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue