Bug Tracker

Opened 11 years ago

Closed 11 years ago

#12134 closed feature (fixed)

implement HTML5 compilant form data construction into $.fn.serialzeArray

Reported by: info@… Owned by: dmethvin
Priority: low Milestone: 1.9
Component: core Version: 1.7.2
Keywords: 1.9-discuss Cc:
Blocked by: Blocking:


The way the data of a form is constructed differs a little bit from the way it is defined in the HTML5 spec. Currently the form data is build using a white list of input[types], while the spec uses a black list. (http://www.w3.org/TR/2011/WD-html5-20110525/association-of-controls-and-forms.html#constructing-form-data-set).

I have created a gist, which suggests 3 code changes:

  1. instead of using this.elements use jQuery.prop( this, "elements" ) to allow polyfills to use a propHook for "elements" and/or implement input[form] and fieldset.elements in a way, that is compilant to serializeArray
  2. Use the whitelist approach by the HTML spec
  3. Use jQuery.is( this, ":disabled" ) instead of this.disabled, because fieldset[disabled] input, won't affect the disabled property, but makes the input truly disabled.

Change History (12)

comment:1 Changed 11 years ago by info@…

I copied the wrong URL for the gist, here ist the right url: You find the gist here: https://gist.github.com/3169103

comment:2 Changed 11 years ago by dmethvin

Component: unfiledcore
Keywords: 1.9-discuss added
Priority: undecidedlow
Status: newopen

The changes seem reasonable and align our handling with HTML5 so it seems like a good idea. Since we're just about ready for a 1.8 release I'll add this for the 1.9 pile.

comment:3 Changed 11 years ago by dmethvin

Type: enhancementfeature

Bulk change from enhancement to feature.

comment:4 Changed 11 years ago by gibson042


comment:5 Changed 11 years ago by mikesherov


comment:6 Changed 11 years ago by Rick Waldron

+1, Definitely and thanks for the report

comment:7 Changed 11 years ago by gibson042


comment:8 Changed 11 years ago by gnarf


comment:9 Changed 11 years ago by mikesherov

Milestone: None1.9
Owner: set to dmethvin
Status: openassigned

comment:10 Changed 11 years ago by dmethvin

@info, would you be able to create some test cases for this code? A pull request would be great as well but I can work from your gist if you prefer.

comment:11 Changed 11 years ago by dmethvin

Unfortunately, oldIE doesn't have querySelectorAll, and Sizzle doesn't currently consider children of a disabled fieldset to be disabled.


I'll land this, but I can't yet create a test case that succeeds on oldIE so I'll open a ticket for the Sizzle issue.

comment:12 Changed 11 years ago by Dave Methvin

Resolution: fixed
Status: assignedclosed

Fix #12134. Make .serialize() HTML5-compliant; provide a propHook for shimming.

Changeset: ae215fdcf843862dbddbdfd68117ac2926e35a42

Note: See TracTickets for help on using tickets.