Fix weird clone bug and add a unit test to verify

This commit is contained in:
Elijah Manor
2012-08-08 15:31:59 -05:00
parent 0d07e7fc2c
commit d5d8622329
2 changed files with 44 additions and 2 deletions

View File

@@ -585,11 +585,17 @@ jQuery.extend({
var srcElements,
destElements,
i,
clone;
clone,
fix8908;
if ( jQuery.support.html5Clone || jQuery.isXMLDoc(elem) || !rnoshimcache.test( "<" + elem.nodeName + ">" ) ) {
clone = elem.cloneNode( true );
// Fixes #8909 - By accessing one of the cloned element's computed styles it breaks the
// connection with the source element's styles in IE9/10
if ( elem.nodeType === 1 && window.getComputedStyle ) {
fix8908 = ( window.getComputedStyle( elem, null ) || {} ).backgroundImage;
}
clone = elem.cloneNode( true );
// IE<=8 does not properly clone detached, unknown element nodes
} else {
fragmentDiv.innerHTML = elem.outerHTML;