Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 18 additions & 51 deletions dist/jquery.form.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,16 +163,15 @@
action = options.url || this.attr2("action");

url = typeof action === "string" ? action.trim() : "";
url = url || window.location.href || "";
url = url || window.location.href;
if (url) {
// clean url (don't include hash vaue)
url = (url.match(/^([^#]+)/) || [])[1];
}
// IE requires javascript:false in https, but this breaks chrome >83 and goes against spec.
// Instead of using javascript:false always, let's only apply it for IE.
isMsie = /(MSIE|Trident)/.test(navigator.userAgent || "");
iframeSrc =
isMsie && /^https/i.test(window.location.href || "") ? "javascript:false" : "about:blank"; // eslint-disable-line no-script-url
iframeSrc = isMsie && /^https/i.test(document.URL) ? "javascript:false" : "about:blank"; // eslint-disable-line no-script-url

options = $.extend(
true,
Expand Down Expand Up @@ -338,10 +337,10 @@
// see: http://groups.google.com/group/jquery-dev/browse_thread/thread/36395b7ab510dd5d
if (options.closeKeepAlive) {
$.get(options.closeKeepAlive, function () {
jqxhr = fileUploadIframe(a);
jqxhr = fileUploadIframe();
});
} else {
jqxhr = fileUploadIframe(a);
jqxhr = fileUploadIframe();
}
} else if ((hasFileInputs || multipart) && fileAPI) {
jqxhr = fileUploadXhr(a);
Expand Down Expand Up @@ -391,9 +390,7 @@
var serializedData = deepSerialize(options.extraData);

for (i = 0; i < serializedData.length; i++) {
if (serializedData[i]) {
formdata.append(serializedData[i][0], serializedData[i][1]);
}
formdata.append(serializedData[i][0], serializedData[i][1]);
}
}

Expand Down Expand Up @@ -466,7 +463,6 @@
xhr,
sub,
n,
timedOut,
timeoutHandle;
var deferred = $.Deferred();

Expand All @@ -475,15 +471,13 @@
xhr.abort(status);
};

if (a) {
// ensure that every serialized input is still enabled
for (i = 0; i < elements.length; i++) {
el = $(elements[i]);
if (hasProp) {
el.prop("disabled", false);
} else {
el.removeAttr("disabled");
}
// ensure that every serialized input is still enabled
for (i = 0; i < elements.length; i++) {
el = $(elements[i]);
if (hasProp) {
el.prop("disabled", false);
} else {
el.removeAttr("disabled");
}
}

Expand Down Expand Up @@ -661,7 +655,6 @@
// support timout
if (s.timeout) {
timeoutHandle = setTimeout(function () {
timedOut = true;
cb(CLIENT_TIMEOUT_ABORT);
}, s.timeout);
}
Expand Down Expand Up @@ -782,11 +775,9 @@
return;
}

if (!doc || doc.location.href === s.iframeSrc) {
if (doc.location.href === s.iframeSrc) {
// response not received yet
if (!timedOut) {
return;
}
return;
}

if (io.detachEvent) {
Expand All @@ -799,10 +790,6 @@
errMsg;

try {
if (timedOut) {
throw "timeout";
}

var isXml = s.dataType === "xml" || doc.XMLDocument || $.isXMLDoc(doc);

log("isXml=" + isXml);
Expand Down Expand Up @@ -863,8 +850,6 @@
xhr.responseText = b.textContent ? b.textContent : b.innerText;
}
}
} else if (dt === "xml" && !xhr.responseXML && xhr.responseText) {
xhr.responseXML = toXml(xhr.responseText); // eslint-disable-line no-use-before-define
}

try {
Expand All @@ -876,7 +861,7 @@
} catch (err) {
log("error caught: ", err);
status = "error";
xhr.error = errMsg = err || status;
xhr.error = errMsg = err;
}

if (xhr.aborted) {
Expand All @@ -892,9 +877,7 @@

// ordering of these callbacks/triggers is odd, but that's how $.ajax does it
if (status === "success") {
if (s.success) {
s.success.call(s.context, data, "success", xhr);
}
s.success.call(s.context, data, "success", xhr);

deferred.resolve(xhr.responseText, "success", xhr);

Expand Down Expand Up @@ -943,22 +926,6 @@
}, 100);
}

var toXml =
$.parseXML ||
function (s, doc) {
// use parseXML if available (jQuery 1.5+)
if (window.ActiveXObject) {
doc = new ActiveXObject("Microsoft.XMLDOM");
doc.async = "false";
doc.loadXML(s);
} else {
doc = new DOMParser().parseFromString(s, "text/xml");
}

return doc && doc.documentElement && doc.documentElement.nodeName !== "parsererror"
? doc
: null;
};
var httpData = function (xhr, type, s) {
// mostly lifted from jq1.4.4

Expand All @@ -977,7 +944,7 @@
if (typeof data === "string") {
if ((type === "json" || !type) && ct.indexOf("json") >= 0) {
data = JSON.parse(data);
} else if ((type === "script" || !type) && ct.indexOf("javascript") >= 0) {
} else if (type === "script") {
$.globalEval(data);
}
}
Expand Down Expand Up @@ -1149,7 +1116,7 @@
if (formId && (semantic || /(Edge|Trident)\//.test(navigator.userAgent))) {
els2 = $(':input[form="' + formId + '"]').get(); // hat tip @thet
if (els2.length) {
els = (els || []).concat(els2);
els = els.concat(els2);
}
}

Expand Down
2 changes: 1 addition & 1 deletion dist/jquery.form.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/jquery.form.min.js.map

Large diffs are not rendered by default.

69 changes: 18 additions & 51 deletions dist/jquery.form.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -139,16 +139,15 @@ export { default } from 'jquery';
action = options.url || this.attr2("action");

url = typeof action === "string" ? action.trim() : "";
url = url || window.location.href || "";
url = url || window.location.href;
if (url) {
// clean url (don't include hash vaue)
url = (url.match(/^([^#]+)/) || [])[1];
}
// IE requires javascript:false in https, but this breaks chrome >83 and goes against spec.
// Instead of using javascript:false always, let's only apply it for IE.
isMsie = /(MSIE|Trident)/.test(navigator.userAgent || "");
iframeSrc =
isMsie && /^https/i.test(window.location.href || "") ? "javascript:false" : "about:blank"; // eslint-disable-line no-script-url
iframeSrc = isMsie && /^https/i.test(document.URL) ? "javascript:false" : "about:blank"; // eslint-disable-line no-script-url

options = $.extend(
true,
Expand Down Expand Up @@ -314,10 +313,10 @@ export { default } from 'jquery';
// see: http://groups.google.com/group/jquery-dev/browse_thread/thread/36395b7ab510dd5d
if (options.closeKeepAlive) {
$.get(options.closeKeepAlive, function () {
jqxhr = fileUploadIframe(a);
jqxhr = fileUploadIframe();
});
} else {
jqxhr = fileUploadIframe(a);
jqxhr = fileUploadIframe();
}
} else if ((hasFileInputs || multipart) && fileAPI) {
jqxhr = fileUploadXhr(a);
Expand Down Expand Up @@ -367,9 +366,7 @@ export { default } from 'jquery';
var serializedData = deepSerialize(options.extraData);

for (i = 0; i < serializedData.length; i++) {
if (serializedData[i]) {
formdata.append(serializedData[i][0], serializedData[i][1]);
}
formdata.append(serializedData[i][0], serializedData[i][1]);
}
}

Expand Down Expand Up @@ -442,7 +439,6 @@ export { default } from 'jquery';
xhr,
sub,
n,
timedOut,
timeoutHandle;
var deferred = $.Deferred();

Expand All @@ -451,15 +447,13 @@ export { default } from 'jquery';
xhr.abort(status);
};

if (a) {
// ensure that every serialized input is still enabled
for (i = 0; i < elements.length; i++) {
el = $(elements[i]);
if (hasProp) {
el.prop("disabled", false);
} else {
el.removeAttr("disabled");
}
// ensure that every serialized input is still enabled
for (i = 0; i < elements.length; i++) {
el = $(elements[i]);
if (hasProp) {
el.prop("disabled", false);
} else {
el.removeAttr("disabled");
}
}

Expand Down Expand Up @@ -637,7 +631,6 @@ export { default } from 'jquery';
// support timout
if (s.timeout) {
timeoutHandle = setTimeout(function () {
timedOut = true;
cb(CLIENT_TIMEOUT_ABORT);
}, s.timeout);
}
Expand Down Expand Up @@ -758,11 +751,9 @@ export { default } from 'jquery';
return;
}

if (!doc || doc.location.href === s.iframeSrc) {
if (doc.location.href === s.iframeSrc) {
// response not received yet
if (!timedOut) {
return;
}
return;
}

if (io.detachEvent) {
Expand All @@ -775,10 +766,6 @@ export { default } from 'jquery';
errMsg;

try {
if (timedOut) {
throw "timeout";
}

var isXml = s.dataType === "xml" || doc.XMLDocument || $.isXMLDoc(doc);

log("isXml=" + isXml);
Expand Down Expand Up @@ -839,8 +826,6 @@ export { default } from 'jquery';
xhr.responseText = b.textContent ? b.textContent : b.innerText;
}
}
} else if (dt === "xml" && !xhr.responseXML && xhr.responseText) {
xhr.responseXML = toXml(xhr.responseText); // eslint-disable-line no-use-before-define
}

try {
Expand All @@ -852,7 +837,7 @@ export { default } from 'jquery';
} catch (err) {
log("error caught: ", err);
status = "error";
xhr.error = errMsg = err || status;
xhr.error = errMsg = err;
}

if (xhr.aborted) {
Expand All @@ -868,9 +853,7 @@ export { default } from 'jquery';

// ordering of these callbacks/triggers is odd, but that's how $.ajax does it
if (status === "success") {
if (s.success) {
s.success.call(s.context, data, "success", xhr);
}
s.success.call(s.context, data, "success", xhr);

deferred.resolve(xhr.responseText, "success", xhr);

Expand Down Expand Up @@ -919,22 +902,6 @@ export { default } from 'jquery';
}, 100);
}

var toXml =
$.parseXML ||
function (s, doc) {
// use parseXML if available (jQuery 1.5+)
if (window.ActiveXObject) {
doc = new ActiveXObject("Microsoft.XMLDOM");
doc.async = "false";
doc.loadXML(s);
} else {
doc = new DOMParser().parseFromString(s, "text/xml");
}

return doc && doc.documentElement && doc.documentElement.nodeName !== "parsererror"
? doc
: null;
};
var httpData = function (xhr, type, s) {
// mostly lifted from jq1.4.4

Expand All @@ -953,7 +920,7 @@ export { default } from 'jquery';
if (typeof data === "string") {
if ((type === "json" || !type) && ct.indexOf("json") >= 0) {
data = JSON.parse(data);
} else if ((type === "script" || !type) && ct.indexOf("javascript") >= 0) {
} else if (type === "script") {
$.globalEval(data);
}
}
Expand Down Expand Up @@ -1125,7 +1092,7 @@ export { default } from 'jquery';
if (formId && (semantic || /(Edge|Trident)\//.test(navigator.userAgent))) {
els2 = $(':input[form="' + formId + '"]').get(); // hat tip @thet
if (els2.length) {
els = (els || []).concat(els2);
els = els.concat(els2);
}
}

Expand Down
Loading
Loading