1
0
mirror of synced 2025-02-03 21:59:24 +03:00

Fixed unit tests and updated source code to handle HTML5 attribs.

This commit is contained in:
Nadim Afana 2016-05-05 21:41:20 -07:00
parent 95b1f8b409
commit a1dc7f23d1
3 changed files with 10 additions and 6 deletions

View File

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

View File

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

View File

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