diff options
author | Dave Methvin <dave.methvin@gmail.com> | 2011-08-04 14:55:21 -0700 |
---|---|---|
committer | Dave Methvin <dave.methvin@gmail.com> | 2011-08-04 14:55:21 -0700 |
commit | 59936dc04d4dd2731874fecd6237383a0e41ddd5 (patch) | |
tree | 83338a8a0ed87bf6201a417d4326e3c4ebf664e5 /test/unit | |
parent | 2e298d92dbba3f9984a7765026e4c3341f709366 (diff) | |
parent | 8fed1e7b5e1248c79b06f5f34d286e27c79b3e57 (diff) | |
download | jquery-59936dc04d4dd2731874fecd6237383a0e41ddd5.tar.gz jquery-59936dc04d4dd2731874fecd6237383a0e41ddd5.zip |
Merge pull request #432 from rwldrn/9794
Correct non-null|undefined evaluation of data property values. Fixes #9779
Diffstat (limited to 'test/unit')
-rw-r--r-- | test/unit/data.js | 26 |
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 ) ); + }); +}); + |