Ticket #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: | |
| Blocking: | Blocked by: |
Description
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:
- 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
- Use the whitelist approach by the HTML spec
- 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
comment:2 Changed 11 months ago by dmethvin
- Keywords 1.9-discuss added
- Priority changed from undecided to low
- Status changed from new to open
- Component changed from unfiled to core
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 9 months ago by dmethvin
- Type changed from enhancement to feature
Bulk change from enhancement to feature.
comment:9 Changed 8 months ago by mikesherov
- Owner set to dmethvin
- Status changed from open to assigned
- Milestone changed from None to 1.9
comment:10 Changed 7 months 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 7 months ago by dmethvin
Unfortunately, oldIE doesn't have querySelectorAll, and Sizzle doesn't currently consider children of a disabled fieldset to be disabled.
http://jsfiddle.net/dmethvin/65QUz/
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 7 months ago by Dave Methvin
- Status changed from assigned to closed
- Resolution set to fixed
Fix #12134. Make .serialize() HTML5-compliant; provide a propHook for shimming.
Changeset: ae215fdcf843862dbddbdfd68117ac2926e35a42
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

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