aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/formdata.rs
diff options
context:
space:
mode:
authorPatrick Shaughnessy <pshaughn@comcast.net>2020-01-20 18:57:43 -0500
committerPatrick Shaughnessy <pshaughn@comcast.net>2020-01-20 19:01:57 -0500
commit4dd27e16487bada0e00e27f2f0c73bd0c8e59daa (patch)
tree3f88c508cff8f2977142264b928e965a6f934b4a /components/script/dom/formdata.rs
parent66aebfdbee6ae10fe7ea65224bf202f53b2efceb (diff)
downloadservo-4dd27e16487bada0e00e27f2f0c73bd0c8e59daa.tar.gz
servo-4dd27e16487bada0e00e27f2f0c73bd0c8e59daa.zip
Files roundtrip through FormData
Diffstat (limited to 'components/script/dom/formdata.rs')
-rw-r--r--components/script/dom/formdata.rs13
1 files changed, 10 insertions, 3 deletions
diff --git a/components/script/dom/formdata.rs b/components/script/dom/formdata.rs
index fd69adbe337..10d1a11f18e 100644
--- a/components/script/dom/formdata.rs
+++ b/components/script/dom/formdata.rs
@@ -185,12 +185,19 @@ impl FormDataMethods for FormData {
impl FormData {
// https://xhr.spec.whatwg.org/#create-an-entry
- // Steps 3-4.
fn create_an_entry(&self, blob: &Blob, opt_filename: Option<USVString>) -> DomRoot<File> {
+ // Steps 3-4
let name = match opt_filename {
Some(filename) => DOMString::from(filename.0),
- None if blob.downcast::<File>().is_none() => DOMString::from("blob"),
- None => DOMString::from(""),
+ None => match blob.downcast::<File>() {
+ None => DOMString::from("blob"),
+ // If it is already a file and no filename was given,
+ // then neither step 3 nor step 4 happens, so instead of
+ // creating a new File object we use the existing one.
+ Some(file) => {
+ return DomRoot::from_ref(file);
+ },
+ },
};
let bytes = blob.get_bytes().unwrap_or(vec![]);