]> source.dussan.org Git - jquery.git/commitdiff
Ref #8908. Update IE9 css clone fix. Close gh-1119.
authorOleg <markelog@gmail.com>
Tue, 8 Jan 2013 02:08:47 +0000 (02:08 +0000)
committerDave Methvin <dave.methvin@gmail.com>
Tue, 8 Jan 2013 02:08:47 +0000 (02:08 +0000)
src/css.js
src/support.js
test/unit/css.js

index 6b800d6d35403995ef540cb7a6aa20539cff0c9f..2a7172759ae53b15891bc7a3d9a004f05aa070c2 100644 (file)
@@ -216,18 +216,13 @@ jQuery.extend({
 
                        // 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 ( !jQuery.support.clearCloneStyle && value === "" && name.indexOf("background") === 0 ) {
+                               style[ name ] = "inherit";
                        }
 
                        // 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 ) {
-
-                               // Wrapped to prevent IE from throwing errors when 'invalid' values are provided
-                               // Fixes bug #5509
-                               try {
-                                       style[ name ] = value;
-                               } catch(e) {}
+                               style[ name ] = value;
                        }
 
                } else {
index f1de07d4521b2d90f45f1bcf0886a54b95fafb74..9950b33d427d28af6f2537e8b8af087a2c1077f3 100644 (file)
@@ -64,6 +64,10 @@ jQuery.support = (function() {
        div.setAttribute( "onfocusin", "t" );
        support.focusinBubbles = "onfocusin" in window || div.attributes.onfocusin.expando === false;
 
+       div.style.backgroundClip = "content-box";
+       div.cloneNode().style.backgroundClip = "";
+       support.clearCloneStyle = div.style.backgroundClip === "content-box";
+
        // Run tests that need a body at doc ready
        jQuery(function() {
                var container, marginDiv, tds,
index abc62593350ac7840a0b512fb89fc6565b9ceece..8513913eed49711d6a14cf47b423516bcbfd7590 100644 (file)
@@ -883,7 +883,7 @@ test( "css opacity consistency across browsers (#12685)", function() {
                equal( Math.round( el.css("opacity") * 100 ), 20, "remove opacity override" );
 });
 
-asyncTest( "Clearing a Cloned Element's Style Shouldn't Clear the Original Element's Style (#8908)", 16, function() {
+asyncTest( "Clearing a Cloned Element's Style Shouldn't Clear the Original Element's Style (#8908)", 24, function() {
        var baseUrl = document.location.href.replace( /([^\/]*)$/, "" ),
        styles = [{
                        name: "backgroundAttachment",
@@ -921,7 +921,7 @@ asyncTest( "Clearing a Cloned Element's Style Shouldn't Clear the Original Eleme
                        expected: [ "auto auto" ]
        }];
 
-       jQuery.each( styles, function(index, style) {
+       jQuery.each(styles, function( index, style ) {
                var $clone, $clonedChildren,
                        $source = jQuery( "#firstp" ),
                        source = $source[ 0 ],
@@ -932,6 +932,7 @@ asyncTest( "Clearing a Cloned Element's Style Shouldn't Clear the Original Eleme
                if ( source.style[ style.name ] === undefined ) {
                        ok( true, style.name +  ": style isn't supported and therefore not an issue" );
                        ok( true );
+
                        return true;
                }
 
@@ -945,6 +946,8 @@ asyncTest( "Clearing a Cloned Element's Style Shouldn't Clear the Original Eleme
                $clonedChildren.css( style.name, "" );
 
                window.setTimeout(function() {
+                       notEqual( $clone.css( style.name ), style.value[ 0 ], "Cloned css was changed" );
+
                        ok( jQuery.inArray( $source.css( style.name ) !== -1, style.value ),
                                "Clearing clone.css() doesn't affect source.css(): " + style.name +
                                "; result: " + $source.css( style.name ) +