aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit/css.js
diff options
context:
space:
mode:
authorOleg <markelog@gmail.com>2012-11-19 02:03:38 +0400
committerDave Methvin <dave.methvin@gmail.com>2012-12-13 10:42:43 -0500
commit643ecf9d63018a7ef907c1e058b778b68ddaf48f (patch)
tree9f907d25d06eecfee52e56d3abab6b288b4d2bbb /test/unit/css.js
parentca26d45395c8a790027633dec5a2ebc15ce9149a (diff)
downloadjquery-643ecf9d63018a7ef907c1e058b778b68ddaf48f.tar.gz
jquery-643ecf9d63018a7ef907c1e058b778b68ddaf48f.zip
Ref #8908, gh-886. Avoid clone identity crisis in IE9/10. Close gh-1036.
Diffstat (limited to 'test/unit/css.js')
-rw-r--r--test/unit/css.js77
1 files changed, 77 insertions, 0 deletions
diff --git a/test/unit/css.js b/test/unit/css.js
index 092be7e09..e7ada8bf9 100644
--- a/test/unit/css.js
+++ b/test/unit/css.js
@@ -923,4 +923,81 @@ 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() {
+ var baseUrl = document.location.href.replace( /([^\/]*)$/, "" ),
+ styles = [{
+ name: "backgroundAttachment",
+ value: ["fixed"],
+ expected: [ "scroll" ]
+ },{
+ name: "backgroundColor",
+ value: [ "rgb(255, 0, 0)", "rgb(255,0,0)", "#ff0000" ],
+ expected: ["transparent"]
+ }, {
+ // Firefox returns auto's value
+ name: "backgroundImage",
+ value: [ "url('test.png')", "url(" + baseUrl + "test.png)", "url(\"" + baseUrl + "test.png\")" ],
+ expected: [ "none", "url(\"http://static.jquery.com/files/rocker/images/logo_jquery_215x53.gif\")" ]
+ }, {
+ name: "backgroundPosition",
+ value: ["5% 5%"],
+ expected: [ "0% 0%", "-1000px 0px", "-1000px 0%" ]
+ }, {
+ // Firefox returns no-repeat
+ name: "backgroundRepeat",
+ value: ["repeat-y"],
+ expected: [ "repeat", "no-repeat" ]
+ }, {
+ name: "backgroundClip",
+ value: ["padding-box"],
+ expected: ["border-box"]
+ }, {
+ name: "backgroundOrigin",
+ value: ["content-box"],
+ expected: ["padding-box"]
+ }, {
+ name: "backgroundSize",
+ value: ["80px 60px"],
+ expected: [ "auto auto" ]
+ }];
+
+ jQuery.each( styles, function(index, style) {
+ var $clone, $clonedChildren,
+ $source = jQuery( "#firstp" ),
+ source = $source[ 0 ],
+ $children = $source.children();
+
+ style.expected = style.expected.concat( [ "", "auto" ] );
+
+ if ( source.style[ style.name ] === undefined ) {
+ ok( true, style.name + ": style isn't supported and therefore not an issue" );
+ ok( true );
+ return true;
+ }
+
+ $source.css( style.name, style.value[ 0 ] );
+ $children.css( style.name, style.value[ 0 ] );
+
+ $clone = $source.clone();
+ $clonedChildren = $clone.children();
+
+ $clone.css( style.name, "" );
+ $clonedChildren.css( style.name, "" );
+
+ window.setTimeout(function() {
+ 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 ) +
+ "; expected: " + style.value.join( "," ) );
+
+ ok( jQuery.inArray( $children.css( style.name ) !== -1, style.value ),
+ "Clearing clonedChildren.css() doesn't affect children.css(): " + style.name +
+ "; result: " + $children.css( style.name ) +
+ "; expected: " + style.value.join( "," ) );
+ }, 100 );
+ });
+
+ window.setTimeout( start, 1000 );
+});
+
}