1
0
mirror of synced 2024-11-25 22:36:03 +03:00

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
caeb0ec9b7.

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.
This commit is contained in:
Kevin Brown 2015-02-24 14:42:27 -05:00
parent dc2f6d451a
commit a9f6d64b72
8 changed files with 18 additions and 7 deletions

1
dist/js/i18n/hi.js vendored Normal file
View File

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

View File

@ -4116,7 +4116,9 @@ define('select2/options',[
$e.data('ajax--url', $e.data('ajax-url')); $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); data = Utils._convertData(data);

View File

@ -4116,7 +4116,9 @@ define('select2/options',[
$e.data('ajax--url', $e.data('ajax-url')); $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); data = Utils._convertData(data);

View File

@ -4555,7 +4555,9 @@ define('select2/options',[
$e.data('ajax--url', $e.data('ajax-url')); $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); data = Utils._convertData(data);

File diff suppressed because one or more lines are too long

4
dist/js/select2.js vendored
View File

@ -4555,7 +4555,9 @@ define('select2/options',[
$e.data('ajax--url', $e.data('ajax-url')); $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); data = Utils._convertData(data);

File diff suppressed because one or more lines are too long

View File

@ -70,7 +70,9 @@ define([
$e.data('ajax--url', $e.data('ajax-url')); $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); data = Utils._convertData(data);