git.asbjorn.biz
/
jquery.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
4a46f3d
)
Tweaked the data number RegExp some to handle some other edge cases.
author
John Resig
<jeresig@gmail.com>
Tue, 21 Sep 2010 04:38:26 +0000
(
00:38
-0400)
committer
John Resig
<jeresig@gmail.com>
Tue, 21 Sep 2010 04:38:26 +0000
(
00:38
-0400)
src/data.js
patch
|
blob
|
history
test/unit/data.js
patch
|
blob
|
history
diff --git
a/src/data.js
b/src/data.js
index
931ea83
..
cc02715
100644
(file)
--- a/
src/data.js
+++ b/
src/data.js
@@
-1,7
+1,7
@@
(function( jQuery ) {
var windowData = {},
(function( jQuery ) {
var windowData = {},
- rnum = /^-?[0-9.]+$/;
+ rnum = /^-?\d+(?:\.\d+)$/;
jQuery.extend({
cache: {},
jQuery.extend({
cache: {},
diff --git
a/test/unit/data.js
b/test/unit/data.js
index
9d43cb5
..
68e24b6
100644
(file)
--- 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() {
});
test("data-* attributes", function() {
- expect(20);
+ expect(22);
var div = jQuery("<div>"),
child = jQuery("<div data-myobj='old data' data-ignored=\"DOM\"></div>");
var div = jQuery("<div>"),
child = jQuery("<div data-myobj='old data' data-ignored=\"DOM\"></div>");
@@
-184,6
+184,8
@@
test("data-* attributes", function() {
.attr("data-false", "false")
.attr("data-five", "5")
.attr("data-point", "5.5")
.attr("data-false", "false")
.attr("data-five", "5")
.attr("data-point", "5.5")
+ .attr("data-pointbad", "5..5")
+ .attr("data-pointbad2", "-.")
.attr("data-null", "null")
.attr("data-string", "test");
.attr("data-null", "null")
.attr("data-string", "test");
@@
-191,6
+193,8
@@
test("data-* attributes", function() {
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('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('null'), null, "Primitive null read from attribute");
equals( child.data('string'), "test", "Typical string read from attribute");
equals( child.data('null'), null, "Primitive null read from attribute");
equals( child.data('string'), "test", "Typical string read from attribute");