]> source.dussan.org Git - jquery.git/commitdiff
Handle some additional data- number edge cases.
authorjeresig <jeresig@gmail.com>
Tue, 21 Sep 2010 12:30:12 +0000 (08:30 -0400)
committerjeresig <jeresig@gmail.com>
Tue, 21 Sep 2010 12:30:12 +0000 (08:30 -0400)
src/data.js
test/unit/data.js

index abe46891ddf8d72038a99673e126911e46a02baf..dc08a563a95adae9dc0bd99a14b94dd02279aafc 100644 (file)
@@ -1,7 +1,7 @@
 (function( jQuery ) {
 
 var windowData = {},
-       rnum = /^-?\d+(?:\.\d+)$/,
+       rnum = /^-?\d+(?:\.\d+)?(?:E\d+)?$/,
        rbrace = /^(?:{.*}|\[.*\])$/;
 
 jQuery.extend({
index f87d7ae4fa8125d18fcff6c3244d0a9f6a42c61d..058f23f4041729c502bfadc8fca637118b6f258f 100644 (file)
@@ -158,7 +158,7 @@ test(".data(String) and .data(String, Object)", function() {
 });
 
 test("data-* attributes", function() {
-       expect(24);
+       expect(25);
        var div = jQuery("<div>"),
                child = jQuery("<div data-myobj='old data' data-ignored=\"DOM\"></div>");
                
@@ -184,6 +184,7 @@ test("data-* attributes", function() {
                .attr("data-false", "false")
                .attr("data-five", "5")
                .attr("data-point", "5.5")
+               .attr("data-pointe", "5.5E3")
                .attr("data-pointbad", "5..5")
                .attr("data-pointbad2", "-.")
                .attr("data-badjson", "{123}")
@@ -191,16 +192,17 @@ test("data-* attributes", function() {
                .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('pointbad'), "5..5", "Bad number read from attribute");
-       equals( child.data('pointbad2'), "-.", "Bad number read from attribute");
-       equals( child.data('badjson'), "{123}", "Bad number read from attribute");
-       equals( child.data('badjson2'), "[abc]", "Bad number read from attribute");
-       equals( child.data('null'), null, "Primitive null read from attribute");
-       equals( child.data('string'), "test", "Typical string read from attribute");
+       strictEqual( child.data('true'), true, "Primitive true read from attribute");
+       strictEqual( child.data('false'), false, "Primitive false read from attribute");
+       strictEqual( child.data('five'), 5, "Primitive number read from attribute");
+       strictEqual( child.data('point'), 5.5, "Primitive number read from attribute");
+       strictEqual( child.data('pointe'), 5500, "Primitive number read from attribute");
+       strictEqual( child.data('pointbad'), "5..5", "Bad number read from attribute");
+       strictEqual( child.data('pointbad2'), "-.", "Bad number read from attribute");
+       strictEqual( child.data('badjson'), "{123}", "Bad number read from attribute");
+       strictEqual( child.data('badjson2'), "[abc]", "Bad number read from attribute");
+       strictEqual( child.data('null'), null, "Primitive null read from attribute");
+       strictEqual( child.data('string'), "test", "Typical string read from attribute");
 
        child.remove();