diff --git a/prive/javascript/jquery.form.js b/prive/javascript/jquery.form.js index 3e428e8d97ba309f3dab47999055698e033855f2..168d4b8b69c06f3ac2760e53fc4bc7841ea7d273 100644 --- a/prive/javascript/jquery.form.js +++ b/prive/javascript/jquery.form.js @@ -1,6 +1,6 @@ /*! * jQuery Form Plugin - * version: 4.2.2 + * version: 4.3.0 * Requires jQuery v1.7.2 or later * Project repository: https://github.com/jquery-form/form @@ -136,7 +136,7 @@ } /* eslint consistent-this: ["error", "$form"] */ - var method, action, url, $form = this; + var method, action, url, isMsie, iframeSrc, $form = this; if (typeof options === 'function') { options = {success: options}; @@ -159,18 +159,22 @@ method = options.method || options.type || this.attr2('method'); action = options.url || this.attr2('action'); - url = (typeof action === 'string') ? action.trim() : ''; + url = (typeof action === 'string') ? $.trim(action) : ''; 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 options = $.extend(true, { url : url, success : $.ajaxSettings.success, type : method || $.ajaxSettings.type, - iframeSrc : /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank' // eslint-disable-line no-script-url + iframeSrc : iframeSrc }, options); // hook for manipulating the form data before it is extracted; @@ -665,12 +669,12 @@ // if using the $.param format that allows for multiple values with the same name if ($.isPlainObject(s.extraData[n]) && s.extraData[n].hasOwnProperty('name') && s.extraData[n].hasOwnProperty('value')) { extraInputs.push( - $('<input type="hidden" name="' + s.extraData[n].name + '">', ownerDocument).val(s.extraData[n].value) - .appendTo(form)[0]); + $('<input type="hidden" name="' + s.extraData[n].name + '">', ownerDocument).val(s.extraData[n].value) + .appendTo(form)[0]); } else { extraInputs.push( - $('<input type="hidden" name="' + n + '">', ownerDocument).val(s.extraData[n]) - .appendTo(form)[0]); + $('<input type="hidden" name="' + n + '">', ownerDocument).val(s.extraData[n]) + .appendTo(form)[0]); } } } @@ -736,7 +740,8 @@ return; - } else if (e === SERVER_ABORT && xhr) { + } + if (e === SERVER_ABORT && xhr) { xhr.abort('server abort'); deferred.reject(xhr, 'error', 'server abort'); @@ -1011,6 +1016,10 @@ return this; } + if (options.beforeFormUnbind) { + options.beforeFormUnbind(this, options); + } + return this.ajaxFormUnbind() .on('submit.form-plugin', options, doAjaxSubmit) .on('click.form-plugin', options, captureSubmittingElement); @@ -1405,7 +1414,7 @@ switch (tag) { case 'input': this.checked = this.defaultChecked; - // fall through + // fall through case 'textarea': this.value = this.defaultValue; @@ -1453,8 +1462,8 @@ return true; case 'form': - // guard against an input with the name of 'reset' - // note that IE reports the reset function as an 'object' + // guard against an input with the name of 'reset' + // note that IE reports the reset function as an 'object' if (typeof this.reset === 'function' || (typeof this.reset === 'object' && !this.reset.nodeType)) { this.reset(); }