From: jeresig Date: Tue, 21 Sep 2010 00:08:57 +0000 (-0400) Subject: Fixing the problem with data-* based numbers as mention by @jasonwebster in 20673d7. X-Git-Url: http://git.asbjorn.biz/?p=jquery.git;a=commitdiff_plain;h=4a46f3d7fbbaa0b7dab49ac815ccec78f1c45d2b Fixing the problem with data-* based numbers as mention by @jasonwebster in 20673d7. --- diff --git a/src/data.js b/src/data.js index f2cfc81..931ea83 100644 --- a/src/data.js +++ b/src/data.js @@ -1,7 +1,7 @@ (function( jQuery ) { var windowData = {}, - rnum = /^-?[0-9.]$/; + rnum = /^-?[0-9.]+$/; jQuery.extend({ cache: {}, diff --git a/test/unit/data.js b/test/unit/data.js index c7307bf..9d43cb5 100644 --- a/test/unit/data.js +++ b/test/unit/data.js @@ -158,7 +158,7 @@ test(".data(String) and .data(String, Object)", function() { }); test("data-* attributes", function() { - expect(19); + expect(20); var div = jQuery("
"), child = jQuery("
"); @@ -183,12 +183,14 @@ test("data-* attributes", function() { .attr("data-true", "true") .attr("data-false", "false") .attr("data-five", "5") + .attr("data-point", "5.5") .attr("data-null", "null") .attr("data-string", "test"); equals( child.data('true'), true, "Primitive true 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('point'), 5.5, "Primitive number read from attribute"); equals( child.data('null'), null, "Primitive null read from attribute"); equals( child.data('string'), "test", "Typical string read from attribute");