diff options
author | John Resig <jeresig@gmail.com> | 2010-09-21 00:51:45 -0400 |
---|---|---|
committer | John Resig <jeresig@gmail.com> | 2010-09-21 00:51:45 -0400 |
commit | e7c2d3b45bf0e8fbe9d7c9316b6c5adb2c019ea3 (patch) | |
tree | 048df322e73af570f47d1e16a0477b66d3cffc37 /test | |
parent | ae9df1412c41b1ae676d3808c323b0f01e0b0600 (diff) | |
download | jquery-e7c2d3b45bf0e8fbe9d7c9316b6c5adb2c019ea3.tar.gz jquery-e7c2d3b45bf0e8fbe9d7c9316b6c5adb2c019ea3.zip |
Added in support for basic JSON object parsing of data- attributes.
Diffstat (limited to 'test')
-rw-r--r-- | test/unit/data.js | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/test/unit/data.js b/test/unit/data.js index 68e24b63d..f360daf7f 100644 --- 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() { - expect(22); + expect(23); var div = jQuery("<div>"), child = jQuery("<div data-myobj='old data' data-ignored=\"DOM\"></div>"); @@ -186,6 +186,7 @@ test("data-* attributes", function() { .attr("data-point", "5.5") .attr("data-pointbad", "5..5") .attr("data-pointbad2", "-.") + .attr("data-badjson", "{123}") .attr("data-null", "null") .attr("data-string", "test"); @@ -195,6 +196,7 @@ test("data-* attributes", function() { 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('null'), null, "Primitive null read from attribute"); equals( child.data('string'), "test", "Typical string read from attribute"); @@ -213,7 +215,7 @@ test("data-* attributes", function() { break; case 2: equals(jQuery(elem).data("zoooo"), "bar", "Check zoooo property"); - equals(jQuery(elem).data("bar"), '{"test":"baz"}', "Check bar property"); + same(jQuery(elem).data("bar"), {"test":"baz"}, "Check bar property"); break; case 3: equals(jQuery(elem).data("number"), true, "Check number property"); |