Add support check, added assertion to check if cleared, add edge case for backgroundPosition

This commit is contained in:
Elijah Manor
2012-08-13 07:46:55 -05:00
parent f952b97997
commit f296335360
7 changed files with 851 additions and 13 deletions

View File

@@ -204,6 +204,9 @@ jQuery.extend({
// 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 ) {
// IE9/10 Clearing Cloned Style Clear's Original Style. Fixes bug #8908
value = !jQuery.support.clearCloneStyle && value === "" && name.match( /backgroundPosition/ ) ? "0% 0%" : value;
// Wrapped to prevent IE from throwing errors when 'invalid' values are provided
// Fixes bug #5509
try {

View File

@@ -585,14 +585,13 @@ jQuery.extend({
var srcElements,
destElements,
i,
clone,
fix8908;
clone;
if ( jQuery.support.html5Clone || jQuery.isXMLDoc(elem) || !rnoshimcache.test( "<" + elem.nodeName + ">" ) ) {
// Fixes #8909 - By accessing one of the element's computed styles it breaks the
// connection with the cloned element's styles in IE9/10
if ( elem.nodeType === 1 && window.getComputedStyle ) {
fix8908 = ( window.getComputedStyle( elem, null ) || {} ).backgroundImage;
if ( !jQuery.support.clearCloneStyle && elem.nodeType === 1 && window.getComputedStyle ) {
i = ( window.getComputedStyle( elem, null ) || {} ).backgroundPosition;
}
clone = elem.cloneNode( true );

View File

@@ -170,6 +170,19 @@ jQuery.support = (function() {
}
}
support.clearCloneStyle = (function() {
var source = document.createElement( "div" ),
styleName = "backgroundClip",
value = "content-box",
clone;
source.style[ styleName ] = value;
clone = source.cloneNode( true );
clone.style[ styleName ] = "";
return source.style[ styleName ] === value;
})();
// Run tests that need a body at doc ready
jQuery(function() {
var container, div, tds, marginDiv,