aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit
diff options
context:
space:
mode:
authorRick Waldron <waldron.rick@gmail.com>2011-07-10 21:42:40 -0400
committerRick Waldron <waldron.rick@gmail.com>2011-07-10 21:45:50 -0400
commit84d066ff7ce38a301fe5cf76a1a79b3a1e754947 (patch)
tree552e5a868c84e7909974c141c7711cb7720da5d6 /test/unit
parent1886d7443453feab0b73f4a7c4b15fbd9401c4af (diff)
downloadjquery-84d066ff7ce38a301fe5cf76a1a79b3a1e754947.tar.gz
jquery-84d066ff7ce38a301fe5cf76a1a79b3a1e754947.zip
Correct non-null|undefined evaluation of data property values. Fixes #9794
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/data.js26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/unit/data.js b/test/unit/data.js
index 87a3de339..c62bd1cc1 100644
--- a/test/unit/data.js
+++ b/test/unit/data.js
@@ -525,3 +525,29 @@ test("jQuery.data should not miss data with preset hyphenated property names", f
equal( div.data(k), k, "data with property '"+k+"' was correctly found");
});
});
+
+test("jQuery.data supports interoperable hyphenated/camelCase get/set of properties with arbitrary non-null|NaN|undefined values", function() {
+
+ var div = jQuery("<div/>", { id: "hyphened" }).appendTo("#qunit-fixture"),
+ datas = {
+ "non-empty": "a string",
+ "empty-string": "",
+ "one-value": 1,
+ "zero-value": 0,
+ "an-array": [],
+ "an-object": {},
+ "bool-true": true,
+ "bool-false": false,
+ "some-json": '{ "foo": "bar" }'
+ };
+
+ expect( 18 );
+
+ jQuery.each( datas, function( key, val ) {
+ div.data( key, val );
+
+ deepEqual( div.data( key ), val, "get: " + key );
+ deepEqual( div.data( jQuery.camelCase( key ) ), val, "get: " + jQuery.camelCase( key ) );
+ });
+});
+