Where is the FormData constructor spec? Am I reading this correctly?

Looking at the w3 spec for FormData there seems to be very very little there. Certainly very little compared with the MDN documentation.

Of most concern, there is nothing here that defines constructor behavior beyond that it must return an instance of FormData. Am I reading this incorrectly, or is the constructor behavior that we get in browsers (as described on MDN) completely unspec’ed?

The document you linked to is outdated, and it is not a final version.

If you look at the top of the document, you see the following:

  • a status: Working Draft (so, not a final spec but an unfinished work-in-progress)
  • a date: 07 September 2010 (so, 6 years old)
  • a link to the current version

If you look at the current version, you will find this note on the current status of the document (bold emphasis mine):

Work on this document has been discontinued and it should not be referenced or used as a basis for implementation. However, the Web Applications Working Group continues to work on XMLHttpRequest Level 1 and the WHATWG continues to work on XMLHttprequest.

This is not specific to XMLHttpRequest, by the way. That is how most of HTML and the surrounding technologies have been working since 2009 or so. Specifications are developed jointly by WHATWG and W3C within WHATWG. WHATWG publishes the specifications as a “Living Document” (meaning, WHATWG doesn’t believe in version numbers, instead the standard is constantly evolving), and every now and then, W3C takes a snapshot of (a subset of) the specifications, and introduces them into their own standardization process.

The latest specs are, in general, always at WHATWG.

If you look at the WHATWG spec on XMLHttpRequest, you will find this section on the FormData interface, which is much more comprehensive:

The FormData(form) constructor must run these steps:

  1. Let fd be a new FormData object.
  2. If form is given, set fd‘s entries to the result of constructing the form data set for form.
  3. Return fd.

By the way: not only does the outdated specification document you posted link to the current spec, but the MDN doc you posted does as well.

Trả lời

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *