diff options
author | Rick Waldron <waldron.rick@gmail.com> | 2011-07-10 21:42:40 -0400 |
---|---|---|
committer | Rick Waldron <waldron.rick@gmail.com> | 2011-07-10 21:45:50 -0400 |
commit | 84d066ff7ce38a301fe5cf76a1a79b3a1e754947 (patch) | |
tree | 552e5a868c84e7909974c141c7711cb7720da5d6 /test/unit | |
parent | 1886d7443453feab0b73f4a7c4b15fbd9401c4af (diff) | |
download | jquery-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.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 ) ); + }); +}); + |