Fixed unit tests and updated source code to handle HTML5 attribs.
This commit is contained in:
parent
95b1f8b409
commit
a1dc7f23d1
3
src/js/select2/options.js
vendored
3
src/js/select2/options.js
vendored
@ -78,7 +78,8 @@ define([
|
||||
}
|
||||
|
||||
$e.attr('ajax--url', Utils.GetData($e[0], 'ajaxUrl'));
|
||||
Utils.StoreData($e[0], 'ajax--url', Utils.GetData($e[0], 'ajaxUrl'));
|
||||
Utils.StoreData($e[0], 'ajax-Url', Utils.GetData($e[0], 'ajaxUrl'));
|
||||
|
||||
}
|
||||
|
||||
var dataset = {};
|
||||
|
8
src/js/select2/utils.js
vendored
8
src/js/select2/utils.js
vendored
@ -303,11 +303,13 @@ define([
|
||||
var id = Utils.GetUniqueElementId(element);
|
||||
if (name) {
|
||||
if (Utils.__cache[id]) {
|
||||
return Utils.__cache[id][name];
|
||||
return Utils.__cache[id][name] != null ?
|
||||
Utils.__cache[id][name]:
|
||||
$(element).data(name); // Fallback to HTML5 data attribs.
|
||||
}
|
||||
return null;
|
||||
return $(element).data(name); // Fallback to HTML5 data attribs.
|
||||
} else {
|
||||
return Utils.__cache[id];
|
||||
return Utils.__cache[id];
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -3,6 +3,7 @@ module('Data adapters - Array');
|
||||
var ArrayData = require('select2/data/array');
|
||||
var $ = require('jquery');
|
||||
var Options = require('select2/options');
|
||||
var Utils = require('select2/utils');
|
||||
|
||||
var arrayOptions = new Options({
|
||||
data: [
|
||||
@ -237,7 +238,7 @@ test('option tags can receive new data', function(assert) {
|
||||
});
|
||||
|
||||
assert.ok(
|
||||
$select.find(':selected').data('data').extra,
|
||||
Utils.GetData($select.find(':selected')[0], 'data').extra,
|
||||
'<option> default should have new data'
|
||||
);
|
||||
|
||||
@ -246,7 +247,7 @@ test('option tags can receive new data', function(assert) {
|
||||
});
|
||||
|
||||
assert.ok(
|
||||
$select.find(':selected').data('data').extra,
|
||||
Utils.GetData($select.find(':selected')[0], 'data').extra,
|
||||
'<option> One should have new data'
|
||||
);
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user