Ref #8908, gh-886. Avoid clone identity crisis in IE9/10. Close gh-1036.

This commit is contained in:
Oleg
2012-11-19 02:03:38 +04:00
committed by Dave Methvin
parent ca26d45395
commit 643ecf9d63
5 changed files with 86 additions and 87 deletions

View File

@@ -211,6 +211,12 @@ jQuery.extend({
value += "px";
}
// Fixes #8908, it can be done more correctly by specifing setters in cssHooks,
// but it would mean to define eight (for every problematic property) identical functions
if ( value === "" && name.indexOf("background") === 0 ) {
value = " ";
}
// If a hook was provided, use that value, otherwise just set the specified value
if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value, extra )) !== undefined ) {
@@ -543,15 +549,6 @@ jQuery.each([ "height", "width" ], function( i, name ) {
};
});
if ( !jQuery.support.clearCloneStyle ) {
// #8908, this part for IE9 only; see gh-886
jQuery.cssHooks.backgroundPosition = {
set: function( elem, value ) {
return value === "" ? "0% 0%" : value;
}
};
}
if ( !jQuery.support.opacity ) {
jQuery.cssHooks.opacity = {
get: function( elem, computed ) {

View File

@@ -433,7 +433,7 @@ function cloneCopyEvent( src, dest ) {
}
}
function cloneFixAttributes( src, dest ) {
function fixCloneNodeIssues( src, dest ) {
var nodeName, data, e;
// We do not need to do anything for non-Elements
@@ -559,12 +559,8 @@ jQuery.extend({
inPage = jQuery.contains( elem.ownerDocument, elem );
if ( jQuery.support.html5Clone || jQuery.isXMLDoc(elem) || !rnoshimcache.test( "<" + elem.nodeName + ">" ) ) {
// Break the original-clone style connection in IE9/10 (#8909)
if ( !jQuery.support.clearCloneStyle && elem.nodeType === 1 ) {
i = ( window.getComputedStyle( elem, null ) || {} ).backgroundPosition;
}
clone = elem.cloneNode( true );
// IE<=8 does not properly clone detached, unknown element nodes
} else {
fragmentDiv.innerHTML = elem.outerHTML;
@@ -582,7 +578,7 @@ jQuery.extend({
for ( i = 0; (node = srcElements[i]) != null; ++i ) {
// Ensure that the destination node is not null; Fixes #9587
if ( destElements[i] ) {
cloneFixAttributes( node, destElements[i] );
fixCloneNodeIssues( node, destElements[i] );
}
}
}

View File

@@ -169,10 +169,6 @@ jQuery.support = (function() {
}
}
div.style.backgroundClip = "content-box";
div.cloneNode( true ).style.backgroundClip = "";
support.clearCloneStyle = div.style.backgroundClip === "content-box";
// Run tests that need a body at doc ready
jQuery(function() {
var container, div, tds, marginDiv,