aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authordanilsomsikov <danilasomsikov@gmail.com>2013-01-11 16:04:50 +0100
committerRichard Gibson <richard.gibson@gmail.com>2013-01-16 14:31:29 -0500
commitcc324abf739669bd2a4669742c994b86c4ad467b (patch)
treed228f17814745d7d0973affa21d92a59e395e619 /test
parenta96aa9e2709b4ba132b966a0f1a13d0e8eb49b9a (diff)
downloadjquery-cc324abf739669bd2a4669742c994b86c4ad467b.tar.gz
jquery-cc324abf739669bd2a4669742c994b86c4ad467b.zip
Fix #8335: Avoid memory leak by never setting data on non-element non-document nodes. Close gh-1127.
Diffstat (limited to 'test')
-rw-r--r--test/unit/data.js13
1 files changed, 12 insertions, 1 deletions
diff --git a/test/unit/data.js b/test/unit/data.js
index 6d1d856f5..34c98140b 100644
--- a/test/unit/data.js
+++ b/test/unit/data.js
@@ -99,8 +99,16 @@ test("jQuery.data(document)", 25, function() {
QUnit.expectJqData(document, "foo");
});
+test("Data is not being set on comment and text nodes", function() {
+ expect(2);
+
+ ok( !jQuery.hasData( jQuery("<!-- comment -->").data("foo", 0) ) );
+ ok( !jQuery.hasData( jQuery("<span>text</span>").contents().data("foo", 0) ) );
+
+});
+
test("jQuery.acceptData", function() {
- expect(7);
+ expect(9);
ok( jQuery.acceptData( document ), "document" );
ok( jQuery.acceptData( document.documentElement ), "documentElement" );
@@ -115,6 +123,9 @@ test("jQuery.acceptData", function() {
var applet = document.createElement("object");
applet.setAttribute("classid", "clsid:8AD9C840-044E-11D1-B3E9-00805F499D93");
ok( !jQuery.acceptData( applet ), "applet" );
+
+ ok( !jQuery.acceptData( document.createComment("") ), "comment" );
+ ok( !jQuery.acceptData( document.createTextNode("") ), "text" );
});
test(".data()", function() {