Skip to content

Commit

Permalink
Fix #11356. Avoid hoarding elements in DocumentFragments.
Browse files Browse the repository at this point in the history
  • Loading branch information
rwaldron authored and dmethvin committed Mar 2, 2012
1 parent 5cae50e commit 1ff284d
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/manipulation.js
Expand Up @@ -676,7 +676,9 @@ jQuery.extend({
var tag = ( rtagName.exec( elem ) || ["", ""] )[1].toLowerCase(),
wrap = wrapMap[ tag ] || wrapMap._default,
depth = wrap[0],
div = context.createElement("div");
div = context.createElement("div"),
safeChildNodes = safeFragment.childNodes,
remove;

// Append wrapper element to unknown element safe doc fragment
if ( context === document ) {
Expand Down Expand Up @@ -721,6 +723,17 @@ jQuery.extend({
}

elem = div.childNodes;

// Clear elements from DocumentFragment (safeFragment or otherwise)
// to avoid hoarding elements. Fixes #11356
if ( div ) {
div.parentNode.removeChild( div );
remove = safeChildNodes[ safeChildNodes.length - 1 ];

if ( remove && remove.parentNode ) {
remove.parentNode.removeChild( remove );
}
}
}
}

Expand Down

0 comments on commit 1ff284d

Please sign in to comment.