소스 검색

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.
Kevin Brown 10 년 전
부모
커밋
e7498987a5
5개의 변경된 파일18개의 추가작업 그리고 10개의 파일을 삭제
  1. 6 4
      dist/js/select2.full.js
  2. 0 0
      dist/js/select2.full.min.js
  3. 6 4
      dist/js/select2.js
  4. 0 0
      dist/js/select2.min.js
  5. 6 2
      src/js/select2/data/ajax.js

+ 6 - 4
dist/js/select2.full.js

@@ -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;
     }
 

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 0 - 0
dist/js/select2.full.min.js


+ 6 - 4
dist/js/select2.js

@@ -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;
     }
 

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 0 - 0
dist/js/select2.min.js


+ 6 - 2
src/js/select2/data/ajax.js

@@ -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;
     }
 

이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.