mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Auto merge of #7433 - frewsxcv:formdata-get, r=nox
Cleanup, refactor FormDataMethods::Get <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7433) <!-- Reviewable:end -->
This commit is contained in:
commit
89a5e2b3d0
1 changed files with 6 additions and 13 deletions
|
@ -85,21 +85,14 @@ impl FormDataMethods for FormData {
|
|||
self.data.borrow_mut().remove(&name);
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
// https://xhr.spec.whatwg.org/#dom-formdata-get
|
||||
fn Get(&self, name: DOMString) -> Option<FileOrString> {
|
||||
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
||||
let data = self.data.borrow();
|
||||
if data.contains_key(&name) {
|
||||
match data[&name][0].clone() {
|
||||
FormDatum::StringData(ref s) => Some(eString(s.clone())),
|
||||
FormDatum::FileData(ref f) => {
|
||||
Some(eFile(f.root()))
|
||||
}
|
||||
}
|
||||
} else {
|
||||
None
|
||||
}
|
||||
self.data.borrow()
|
||||
.get(&name)
|
||||
.map(|entry| match entry[0] {
|
||||
FormDatum::StringData(ref s) => eString(s.clone()),
|
||||
FormDatum::FileData(ref f) => eFile(f.root()),
|
||||
})
|
||||
}
|
||||
|
||||
// https://xhr.spec.whatwg.org/#dom-formdata-has
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue