Fix #8335: Avoid memory leak by never setting data on non-element non-document nodes. Close gh-1127.

This commit is contained in:
danilsomsikov
2013-01-11 16:04:50 +01:00
committed by Richard Gibson
parent a96aa9e270
commit cc324abf73
2 changed files with 17 additions and 1 deletions

View File

@@ -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