aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbors-servo <metajack+bors@gmail.com>2015-08-30 07:00:33 -0600
committerbors-servo <metajack+bors@gmail.com>2015-08-30 07:00:33 -0600
commit89a5e2b3d098fc2afdb95ebcebeb8d7beeebc96a (patch)
tree44fce438f94ded200ed81c01cbb18ebe25eb045e
parent67cbda4be35a63222553ca806d475581030bea4e (diff)
parentb0d2194a4a2700418b719e20cbf5bb24831f1a92 (diff)
downloadservo-89a5e2b3d098fc2afdb95ebcebeb8d7beeebc96a.tar.gz
servo-89a5e2b3d098fc2afdb95ebcebeb8d7beeebc96a.zip
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 -->
-rw-r--r--components/script/dom/formdata.rs19
1 files changed, 6 insertions, 13 deletions
diff --git a/components/script/dom/formdata.rs b/components/script/dom/formdata.rs
index 8390430c39e..8631cefbd4a 100644
--- a/components/script/dom/formdata.rs
+++ b/components/script/dom/formdata.rs
@@ -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