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'));
|
$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 = {};
|
var dataset = {};
|
||||||
|
6
src/js/select2/utils.js
vendored
6
src/js/select2/utils.js
vendored
@ -303,9 +303,11 @@ define([
|
|||||||
var id = Utils.GetUniqueElementId(element);
|
var id = Utils.GetUniqueElementId(element);
|
||||||
if (name) {
|
if (name) {
|
||||||
if (Utils.__cache[id]) {
|
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 {
|
} else {
|
||||||
return Utils.__cache[id];
|
return Utils.__cache[id];
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ module('Data adapters - Array');
|
|||||||
var ArrayData = require('select2/data/array');
|
var ArrayData = require('select2/data/array');
|
||||||
var $ = require('jquery');
|
var $ = require('jquery');
|
||||||
var Options = require('select2/options');
|
var Options = require('select2/options');
|
||||||
|
var Utils = require('select2/utils');
|
||||||
|
|
||||||
var arrayOptions = new Options({
|
var arrayOptions = new Options({
|
||||||
data: [
|
data: [
|
||||||
@ -237,7 +238,7 @@ test('option tags can receive new data', function(assert) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
assert.ok(
|
assert.ok(
|
||||||
$select.find(':selected').data('data').extra,
|
Utils.GetData($select.find(':selected')[0], 'data').extra,
|
||||||
'<option> default should have new data'
|
'<option> default should have new data'
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -246,7 +247,7 @@ test('option tags can receive new data', function(assert) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
assert.ok(
|
assert.ok(
|
||||||
$select.find(':selected').data('data').extra,
|
Utils.GetData($select.find(':selected')[0], 'data').extra,
|
||||||
'<option> One should have new data'
|
'<option> One should have new data'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user