[whatwg] Adding FormData support to <form>

Dmitry Titov dimich at google.com
Fri Feb 19 08:52:49 PST 2010


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-0001.htm>


More information about the whatwg mailing list