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

index 210bed2e803e0d54cce514e8699f772ac1276973..7ddce0a04456b38afb8fe8ada7bffb0f6c5274ba 100644 (file)
@@ -213,8 +213,8 @@ 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
index c99bb392222c9abdf33b6a1565997da4c9ea049b..4960930efb49419f29f3371bd47c1b81ef6ebea0 100644 (file)
@@ -138,6 +138,10 @@ jQuery.support = (function() {
                support[ i + "Bubbles" ] = eventName in window || div.attributes[ eventName ].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 e7ada8bf90c59f3a4c954d8c3472cc88511ce75f..d8f7c01d40698d4fe62bd040224efb0b360a8a36 100644 (file)
@@ -923,7 +923,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",
@@ -961,7 +961,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 ],
@@ -972,6 +972,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 );
+                       ok( true );
                        return true;
                }
 
@@ -985,6 +986,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 ) +
index 76a0af7b745ab3126c4db43cda3a9bbb650d4e49..356751d22ab597d9672ebc0420632c12da0a1fb2 100644 (file)
@@ -81,7 +81,8 @@ testIframeWithCallback( "box-sizing does not affect jQuery.support.shrinkWrapBlo
                        "reliableHiddenOffsets":true,
                        "ajax":true,
                        "cors":true,
-                       "doesNotIncludeMarginInBodyOffset":true
+                       "doesNotIncludeMarginInBodyOffset":true,
+                       "clearCloneStyle": true
                };
        } else if ( /opera.*version\/12\.1/i.test( userAgent ) ) {
                expected = {
@@ -114,7 +115,8 @@ testIframeWithCallback( "box-sizing does not affect jQuery.support.shrinkWrapBlo
                        "reliableHiddenOffsets":true,
                        "ajax":true,
                        "cors":true,
-                       "doesNotIncludeMarginInBodyOffset":true
+                       "doesNotIncludeMarginInBodyOffset":true,
+                       "clearCloneStyle": true
                };
        } else if ( /msie 10\.0/i.test( userAgent ) ) {
                expected = {
@@ -147,7 +149,8 @@ testIframeWithCallback( "box-sizing does not affect jQuery.support.shrinkWrapBlo
                        "reliableHiddenOffsets":true,
                        "ajax":true,
                        "cors":true,
-                       "doesNotIncludeMarginInBodyOffset":true
+                       "doesNotIncludeMarginInBodyOffset":true,
+                       "clearCloneStyle": false
                };
        } else if ( /msie 9\.0/i.test( userAgent ) ) {
                expected = {
@@ -180,7 +183,8 @@ testIframeWithCallback( "box-sizing does not affect jQuery.support.shrinkWrapBlo
                        "reliableHiddenOffsets":true,
                        "ajax":true,
                        "cors":false,
-                       "doesNotIncludeMarginInBodyOffset":true
+                       "doesNotIncludeMarginInBodyOffset":true,
+                       "clearCloneStyle": false
                };
        } else if ( /msie 8\.0/i.test( userAgent ) ) {
                expected = {
@@ -213,7 +217,8 @@ testIframeWithCallback( "box-sizing does not affect jQuery.support.shrinkWrapBlo
                        "reliableHiddenOffsets":false,
                        "ajax":true,
                        "cors":false,
-                       "doesNotIncludeMarginInBodyOffset":true
+                       "doesNotIncludeMarginInBodyOffset":true,
+                       "clearCloneStyle": true
                };
        } else if ( /msie 7\.0/i.test( userAgent ) ) {
                expected = {
@@ -246,7 +251,8 @@ testIframeWithCallback( "box-sizing does not affect jQuery.support.shrinkWrapBlo
                        "shrinkWrapBlocks": false,
                        "submitBubbles": false,
                        "tbody": false,
-                       "style": false
+                       "style": false,
+                       "clearCloneStyle": true
                };
        } else if ( /msie 6\.0/i.test( userAgent ) ) {
                expected = {
@@ -279,7 +285,8 @@ testIframeWithCallback( "box-sizing does not affect jQuery.support.shrinkWrapBlo
                        "reliableHiddenOffsets":false,
                        "ajax":true,
                        "cors":false,
-                       "doesNotIncludeMarginInBodyOffset":true
+                       "doesNotIncludeMarginInBodyOffset":true,
+                       "clearCloneStyle": true
                };
        } else if ( /5\.1\.1 safari/i.test( userAgent ) ) {
                expected = {
@@ -312,7 +319,8 @@ testIframeWithCallback( "box-sizing does not affect jQuery.support.shrinkWrapBlo
                        "reliableHiddenOffsets":true,
                        "ajax":true,
                        "cors":true,
-                       "doesNotIncludeMarginInBodyOffset":true
+                       "doesNotIncludeMarginInBodyOffset":true,
+                       "clearCloneStyle": true
                };
        } else if ( /firefox/i.test( userAgent ) ) {
                expected = {
@@ -345,13 +353,14 @@ testIframeWithCallback( "box-sizing does not affect jQuery.support.shrinkWrapBlo
                        "reliableHiddenOffsets":true,
                        "ajax":true,
                        "cors":true,
-                       "doesNotIncludeMarginInBodyOffset":true
+                       "doesNotIncludeMarginInBodyOffset":true,
+                       "clearCloneStyle": true
                };
        }
 
        if ( expected ) {
                test("Verify that the support tests resolve as expected per browser", function() {
-                       expect( 30 );
+                       expect( 31 );
 
                        for ( var i in expected ) {
                                if ( jQuery.ajax || i !== "ajax" && i !== "cors" ) {