소스 검색

Added `.dataset` fallback for jQuery 1.x

As we have established already, jQuery 1.x does not correctly handle
`data-*` attributes where there are multiple dashes.  This makes it
so we can still handle nested options when working with jQuery 1.x
by using the `.dataset` option that is supported by all major
browsers as well as IE 11+.

Browser support tables for the `.dataset` attributes can be found at
http://caniuse.com/dataset

A notice was already added to the documentation about this in
https://github.com/select2/select2/commit/caeb0ec9b775baf1b91cad859a2954d720d3af20.

The related ticket in the jQuery repository about this issue is
https://github.com/jquery/jquery/issues/2070.

This closes https://github.com/select2/select2/issues/2969.
Kevin Brown 10 년 전
부모
커밋
a9f6d64b72
8개의 변경된 파일16개의 추가작업 그리고 5개의 파일을 삭제
  1. 1 0
      dist/js/i18n/hi.js
  2. 3 1
      dist/js/select2.amd.full.js
  3. 3 1
      dist/js/select2.amd.js
  4. 3 1
      dist/js/select2.full.js
  5. 0 0
      dist/js/select2.full.min.js
  6. 3 1
      dist/js/select2.js
  7. 0 0
      dist/js/select2.min.js
  8. 3 1
      src/js/select2/options.js

+ 1 - 0
dist/js/i18n/hi.js

@@ -0,0 +1 @@
+(function(){if(window.define)var e=window.define;if(window.require)var t=window.require;if(window.jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd.define,t=jQuery.fn.select2.amd.require;e("select2/i18n/hi",[],function(){return{errorLoading:function(){return"परिणामों को लोड नहीं किया जा सका।"},inputTooLong:function(e){var t=e.input.length-e.maximum,n=t+" अक्षर को हटा दें";return t>1&&(n=t+" अक्षरों को हटा दें "),n},inputTooShort:function(e){var t=e.minimum-e.input.length,n="कृपया "+t+" या अधिक अक्षर दर्ज करें";return n},loadingMore:function(){return"अधिक परिणाम लोड हो रहे है..."},maximumSelected:function(e){var t="आप केवल "+e.maximum+" आइटम का चयन कर सकते हैं";return t},noResults:function(){return"कोई परिणाम नहीं मिला"},searching:function(){return"खोज रहा है..."}}}),t("jquery.select2"),jQuery.fn.select2.amd={define:e,require:t}})();

+ 3 - 1
dist/js/select2.amd.full.js

@@ -4116,7 +4116,9 @@ define('select2/options',[
       $e.data('ajax--url', $e.data('ajax-url'));
     }
 
-    var data = $e.data();
+    // Prefer the element's `dataset` attribute if it exists
+    // jQuery 1.x does not correctly handle data attributes with multiple dashes
+    var data = $.extend(true, {}, $e[0].dataset || $e.data());
 
     data = Utils._convertData(data);
 

+ 3 - 1
dist/js/select2.amd.js

@@ -4116,7 +4116,9 @@ define('select2/options',[
       $e.data('ajax--url', $e.data('ajax-url'));
     }
 
-    var data = $e.data();
+    // Prefer the element's `dataset` attribute if it exists
+    // jQuery 1.x does not correctly handle data attributes with multiple dashes
+    var data = $.extend(true, {}, $e[0].dataset || $e.data());
 
     data = Utils._convertData(data);
 

+ 3 - 1
dist/js/select2.full.js

@@ -4555,7 +4555,9 @@ define('select2/options',[
       $e.data('ajax--url', $e.data('ajax-url'));
     }
 
-    var data = $e.data();
+    // Prefer the element's `dataset` attribute if it exists
+    // jQuery 1.x does not correctly handle data attributes with multiple dashes
+    var data = $.extend(true, {}, $e[0].dataset || $e.data());
 
     data = Utils._convertData(data);
 

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


+ 3 - 1
dist/js/select2.js

@@ -4555,7 +4555,9 @@ define('select2/options',[
       $e.data('ajax--url', $e.data('ajax-url'));
     }
 
-    var data = $e.data();
+    // Prefer the element's `dataset` attribute if it exists
+    // jQuery 1.x does not correctly handle data attributes with multiple dashes
+    var data = $.extend(true, {}, $e[0].dataset || $e.data());
 
     data = Utils._convertData(data);
 

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


+ 3 - 1
src/js/select2/options.js

@@ -70,7 +70,9 @@ define([
       $e.data('ajax--url', $e.data('ajax-url'));
     }
 
-    var data = $e.data();
+    // Prefer the element's `dataset` attribute if it exists
+    // jQuery 1.x does not correctly handle data attributes with multiple dashes
+    var data = $.extend(true, {}, $e[0].dataset || $e.data());
 
     data = Utils._convertData(data);
 

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