-
Notifications
You must be signed in to change notification settings - Fork 432
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Option includeDisabled #119
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
/* --- */ | ||
/*! | ||
SerializeJSON jQuery plugin. | ||
https://github.com/marioizquierdo/jquery.serializeJSON | ||
version 3.2.1 (Feb, 2021) | ||
version 3.2.2 (Mar, 2021) | ||
|
||
Copyright (c) 2012-2021 Mario Izquierdo | ||
Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) | ||
|
@@ -50,6 +51,10 @@ | |
if (type === "skip") { | ||
return; // ignore fields with type skip | ||
} | ||
if(obj.multiple) { | ||
type = 'array'; | ||
} | ||
|
||
if (!type) { | ||
type = opts.defaultType; // "string" by default | ||
} | ||
|
@@ -108,7 +113,8 @@ | |
"disableColonTypes", | ||
"customTypes", | ||
"defaultTypes", | ||
"defaultType" | ||
"defaultType", | ||
"includeDisabled" | ||
]; | ||
for (var opt in options) { | ||
if (validOpts.indexOf(opt) === -1) { | ||
|
@@ -133,10 +139,9 @@ | |
}).filter(function() { | ||
var $el = $(this); | ||
var type = this.type; | ||
|
||
// Filter with the standard W3C rules for successful controls: http://www.w3.org/TR/html401/interact/forms.html#h-17.13.2 | ||
return this.name && // must contain a name attribute | ||
!$el.is(":disabled") && // must not be disable (use .is(":disabled") so that fieldset[disabled] works) | ||
(!$el.is(":disabled") || $el.is(":disabled") && opts.includeDisabled) && // must not be disable (use .is(":disabled") so that fieldset[disabled] works) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. check seems equivalent to |
||
rsubmittable.test(this.nodeName) && !rsubmitterTypes.test(type) && // only serialize submittable fields (and not buttons) | ||
(this.checked || !rcheckableType.test(type) || f.getCheckboxUncheckedValue($el, opts) != null); // skip unchecked checkboxes (unless using opts) | ||
|
||
|
@@ -154,13 +159,14 @@ | |
} | ||
|
||
if (isArray(val)) { | ||
return $.map(val, function(val) { | ||
return { name: el.name, value: val.replace(rCRLF, "\r\n"), el: el }; | ||
} ); | ||
if(!val.length) { | ||
return { name: el.name, el: el } | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. when would the array not have a length property? Should that not be factored into the |
||
return $.map(val, function(val) { | ||
return { name: el.name, value: val.replace(rCRLF, "\r\n"), el: el}; | ||
} ); | ||
} | ||
|
||
return { name: el.name, value: val.replace(rCRLF, "\r\n"), el: el }; | ||
|
||
}).get(); | ||
}, | ||
|
||
|
@@ -336,3 +342,5 @@ | |
var isValidArrayIndex = function(val) { return /^[0-9]+$/.test(String(val)); }; // 1,2,3,4 ... are valid array indexes | ||
var isArray = Array.isArray || function(obj) { return Object.prototype.toString.call(obj) === "[object Array]"; }; | ||
})); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this check? Maybe we should explain in a comment for clarity