Fix abort with JSONP
We now check that the `abort` method actually exists before aborting the request, as JSONP does not include the `abort` method because a JSONP request technically cannot be aborted. This closes https://github.com/select2/select2/issues/3217.
This commit is contained in:
parent
a8e6cbc0c9
commit
e7498987a5
10
dist/js/select2.full.js
vendored
10
dist/js/select2.full.js
vendored
@ -1668,8 +1668,6 @@ S2.define('select2/selection/allowClear',[
|
||||
};
|
||||
|
||||
AllowClear.prototype._handleClear = function (_, evt) {
|
||||
console.log(arguments);
|
||||
|
||||
// Ignore the event if it is disabled
|
||||
if (this.options.get('disabled')) {
|
||||
return;
|
||||
@ -3275,8 +3273,12 @@ S2.define('select2/data/ajax',[
|
||||
var matches = [];
|
||||
var self = this;
|
||||
|
||||
if (this._request) {
|
||||
this._request.abort();
|
||||
if (this._request != null) {
|
||||
// JSONP requests cannot always be aborted
|
||||
if ($.isFunction(this._request.abort)) {
|
||||
this._request.abort();
|
||||
}
|
||||
|
||||
this._request = null;
|
||||
}
|
||||
|
||||
|
6
dist/js/select2.full.min.js
vendored
6
dist/js/select2.full.min.js
vendored
File diff suppressed because one or more lines are too long
10
dist/js/select2.js
vendored
10
dist/js/select2.js
vendored
@ -1668,8 +1668,6 @@ S2.define('select2/selection/allowClear',[
|
||||
};
|
||||
|
||||
AllowClear.prototype._handleClear = function (_, evt) {
|
||||
console.log(arguments);
|
||||
|
||||
// Ignore the event if it is disabled
|
||||
if (this.options.get('disabled')) {
|
||||
return;
|
||||
@ -3275,8 +3273,12 @@ S2.define('select2/data/ajax',[
|
||||
var matches = [];
|
||||
var self = this;
|
||||
|
||||
if (this._request) {
|
||||
this._request.abort();
|
||||
if (this._request != null) {
|
||||
// JSONP requests cannot always be aborted
|
||||
if ($.isFunction(this._request.abort)) {
|
||||
this._request.abort();
|
||||
}
|
||||
|
||||
this._request = null;
|
||||
}
|
||||
|
||||
|
4
dist/js/select2.min.js
vendored
4
dist/js/select2.min.js
vendored
File diff suppressed because one or more lines are too long
8
src/js/select2/data/ajax.js
vendored
8
src/js/select2/data/ajax.js
vendored
@ -43,8 +43,12 @@ define([
|
||||
var matches = [];
|
||||
var self = this;
|
||||
|
||||
if (this._request) {
|
||||
this._request.abort();
|
||||
if (this._request != null) {
|
||||
// JSONP requests cannot always be aborted
|
||||
if ($.isFunction(this._request.abort)) {
|
||||
this._request.abort();
|
||||
}
|
||||
|
||||
this._request = null;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user