aboutsummaryrefslogtreecommitdiffstats
path: root/src
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 /src
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 'src')
-rw-r--r--src/data.js5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/data.js b/src/data.js
index d5a25ff6c..eaa483813 100644
--- a/src/data.js
+++ b/src/data.js
@@ -223,6 +223,11 @@ jQuery.extend({
// A method for determining if a DOM node can handle the data expando
acceptData: function( elem ) {
+ // Do not set data on non-element because it will not be cleared (#8335).
+ if ( elem.nodeType && elem.nodeType !== 1 && elem.nodeType !== 9 ) {
+ return false;
+ }
+
var noData = elem.nodeName && jQuery.noData[ elem.nodeName.toLowerCase() ];
// nodes accept data unless otherwise specified; rejection can be conditional