]> source.dussan.org Git - jquery.git/commitdiff
Fixing the problem with data-* based numbers as mention by @jasonwebster in 20673d7.
authorjeresig <jeresig@gmail.com>
Tue, 21 Sep 2010 00:08:57 +0000 (20:08 -0400)
committerjeresig <jeresig@gmail.com>
Tue, 21 Sep 2010 00:08:57 +0000 (20:08 -0400)
src/data.js
test/unit/data.js

index f2cfc81ce210f7e55b57817422c009f122324ca7..931ea83847225cf1d8e686db418b551bf6474f47 100644 (file)
@@ -1,7 +1,7 @@
 (function( jQuery ) {
 
 var windowData = {},
-       rnum = /^-?[0-9.]$/;
+       rnum = /^-?[0-9.]+$/;
 
 jQuery.extend({
        cache: {},
index c7307bfd6580e827c243cc290cb16ba7e3c6a079..9d43cb59af1b369d53bf75c59293d63e789ed291 100644 (file)
@@ -158,7 +158,7 @@ test(".data(String) and .data(String, Object)", function() {
 });
 
 test("data-* attributes", function() {
-       expect(19);
+       expect(20);
        var div = jQuery("<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-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");