W3C home > Mailing lists > Public > whatwg@whatwg.org > February 2010

[whatwg] Adding FormData support to <form>

From: Dmitry Titov <dimich@google.com>
Date: Fri, 19 Feb 2010 08:52:49 -0800
Message-ID: <28040fc61002190852m455b47bcq916abbbf2a12f804@mail.gmail.com>
On Thu, Feb 18, 2010 at 8:45 PM, Maciej Stachowiak <mjs at apple.com> wrote:

>
> On Feb 17, 2010, at 3:15 PM, Jonas Sicking wrote:
>
>  The reason this is a function rather than a read-only attribute is to
>> allow the return FormData to be further modified. I.e. the following
>> should be allowed:
>>
>> fd = myFormElement.getFormData();
>> fd.append("foo", "bar");
>> xhr.send(fd);
>>
>> If it was a property I would be worried about people expecting the
>> following to work:
>> myFormElement.formData.append("foo", "bar");
>> xhr.send(myFormElement.formData);
>>
>> However I don't think there is a good way to make the above work. Thus
>> my suggestion to use a function instead. I'm writing a prototype
>> implementation over in [2]
>>
>
> People could imagine that this should work:
>
> myFormElement.getFormData().append("foo", "bar");
> xhr.send(myFormElement.getFormData());
>
> In either case, it seems that once they see it doesn't work, they will no
> longer expect it to work.
>

Sure, but a better name could help a bit. For example, this produces a
'shared' object:

document.getElementById("foo")

while this creates a new one:

myFormElement.getFormData()

It might be ok, but it is a bit inconsistent.

Why not:
formData = new FormData();
formData = new FormData(myFormElement);


Regards,
> Maciej
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.whatwg.org/pipermail/whatwg-whatwg.org/attachments/20100219/0ac86041/attachment.htm>
Received on Friday, 19 February 2010 08:52:49 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:21 UTC