diff options
author | Oleg Gaidarenko <markelog@gmail.com> | 2013-04-08 15:10:39 -0400 |
---|---|---|
committer | Rick Waldron <waldron.rick@gmail.com> | 2013-04-08 15:10:39 -0400 |
commit | f61314ff5cb5e6b620ace758a6f00c94a3031154 (patch) | |
tree | 1789bfb7153fe7e1640c49499a1d0fed5be27974 /test | |
parent | aadae5058a44e745ebdbee5d5333402699326188 (diff) | |
download | jquery-f61314ff5cb5e6b620ace758a6f00c94a3031154.tar.gz jquery-f61314ff5cb5e6b620ace758a6f00c94a3031154.zip |
Fixes #8335. Do not allow add data to non-elements (2.x). Closes gh-1232
Diffstat (limited to 'test')
-rw-r--r-- | test/unit/data.js | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/test/unit/data.js b/test/unit/data.js index 68426dc28..326fc5e2d 100644 --- a/test/unit/data.js +++ b/test/unit/data.js @@ -170,14 +170,6 @@ test("jQuery.data(object/flash)", 25, function() { dataTests( flash ); }); -test("jQuery.data(comment)", 25, function() { - dataTests( document.createComment("") ); -}); - -test("jQuery.data(text)", 25, function() { - dataTests( document.createTextNode("") ); -}); - test(".data()", function() { expect(5); @@ -685,3 +677,23 @@ test(".data doesn't throw when calling selection is empty. #13551", function() { ok( false, e.message ); } }); + +test("jQuery.acceptData", 6, function() { + ok( jQuery.acceptData( document ), "document" ); + ok( jQuery.acceptData( document.documentElement ), "documentElement" ); + ok( jQuery.acceptData( {} ), "object" ); + + ok( !jQuery.acceptData( document.createComment("") ), "comment" ); + ok( !jQuery.acceptData( document.createTextNode("") ), "text" ); + ok( !jQuery.acceptData( document.createDocumentFragment() ), "documentFragment" ); +}); + +test("Check proper data removal of non-element descendants nodes (#8335)", 1, function() { + var div = jQuery("<div>text</div>"), + text = div.contents(); + + text.data( "test", "test" ); // This should be a noop. + div.remove(); + + ok( !text.data("test"), "Be sure data is not stored in non-element" ); +}); |