Fixing the problem with data-* based numbers as mention by @jasonwebster in 20673d7
.
This commit is contained in:
parent
653c04acb8
commit
4a46f3d7fb
|
@ -1,7 +1,7 @@
|
||||||
(function( jQuery ) {
|
(function( jQuery ) {
|
||||||
|
|
||||||
var windowData = {},
|
var windowData = {},
|
||||||
rnum = /^-?[0-9.]$/;
|
rnum = /^-?[0-9.]+$/;
|
||||||
|
|
||||||
jQuery.extend({
|
jQuery.extend({
|
||||||
cache: {},
|
cache: {},
|
||||||
|
|
|
@ -158,7 +158,7 @@ test(".data(String) and .data(String, Object)", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test("data-* attributes", function() {
|
test("data-* attributes", function() {
|
||||||
expect(19);
|
expect(20);
|
||||||
var div = jQuery("<div>"),
|
var div = jQuery("<div>"),
|
||||||
child = jQuery("<div data-myobj='old data' data-ignored=\"DOM\"></div>");
|
child = jQuery("<div data-myobj='old data' data-ignored=\"DOM\"></div>");
|
||||||
|
|
||||||
|
@ -183,12 +183,14 @@ test("data-* attributes", function() {
|
||||||
.attr("data-true", "true")
|
.attr("data-true", "true")
|
||||||
.attr("data-false", "false")
|
.attr("data-false", "false")
|
||||||
.attr("data-five", "5")
|
.attr("data-five", "5")
|
||||||
|
.attr("data-point", "5.5")
|
||||||
.attr("data-null", "null")
|
.attr("data-null", "null")
|
||||||
.attr("data-string", "test");
|
.attr("data-string", "test");
|
||||||
|
|
||||||
equals( child.data('true'), true, "Primitive true read from attribute");
|
equals( child.data('true'), true, "Primitive true read from attribute");
|
||||||
equals( child.data('false'), false, "Primitive false read from attribute");
|
equals( child.data('false'), false, "Primitive false read from attribute");
|
||||||
equals( child.data('five'), 5, "Primitive number read from attribute");
|
equals( child.data('five'), 5, "Primitive number read from attribute");
|
||||||
|
equals( child.data('point'), 5.5, "Primitive number read from attribute");
|
||||||
equals( child.data('null'), null, "Primitive null read from attribute");
|
equals( child.data('null'), null, "Primitive null read from attribute");
|
||||||
equals( child.data('string'), "test", "Typical string read from attribute");
|
equals( child.data('string'), "test", "Typical string read from attribute");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue