Skip to content

Instantly share code, notes, and snippets.

@ddstreet
Created March 11, 2011 17:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ddstreet/866242 to your computer and use it in GitHub Desktop.
Save ddstreet/866242 to your computer and use it in GitHub Desktop.
diff --git a/ui/jquery.effects.core.js b/ui/jquery.effects.core.js
index 71f775a..9046eff 100644
--- a/ui/jquery.effects.core.js
+++ b/ui/jquery.effects.core.js
@@ -232,9 +232,9 @@ $.effects.animateClass = function( value, duration, easing, callback ) {
return this.queue( 'fx', function() {
var that = $( this ),
- originalStyleAttr = that.attr( 'style' ) || ' ',
+ originalStyleObj = $.extend( {}, that[ 0 ].style ),
originalStyle = filterStyles( getElementStyles.call( this ) ),
- newStyle,
+ styleDiff,
className = that.attr( 'className' );
$.each( classAnimationActions, function(i, action) {
@@ -242,22 +242,18 @@ $.effects.animateClass = function( value, duration, easing, callback ) {
that[ action + 'Class' ]( value[ action ] );
}
});
- newStyle = filterStyles( getElementStyles.call( this ) );
+ styleDiff = styleDifference( originalStyle, filterStyles( getElementStyles.call( this ) ) );
that.attr( 'className', className );
- that.animate( styleDifference( originalStyle, newStyle ), duration, easing, function() {
+ that.animate( styleDiff, duration, easing, function() {
$.each( classAnimationActions, function( i, action ) {
if ( value[ action ] ) {
that[ action + 'Class' ]( value[ action ] );
}
});
- // work around bug in IE by clearing the cssText before setting it
- if ( typeof that.attr( 'style' ) == 'object' ) {
- that.attr( 'style' ).cssText = '';
- that.attr( 'style' ).cssText = originalStyleAttr;
- } else {
- that.attr( 'style', originalStyleAttr );
- }
+ $.each( styleDiff, function() {
+ that[ 0 ].style[ this ] = originalStyleObj[ this ];
+ });
if ( callback ) {
callback.apply( this, arguments );
}
diff --git a/tests/unit/core/core.html b/tests/unit/core/core.html
index 31702dd..2330771 100644
--- a/tests/unit/core/core.html
+++ b/tests/unit/core/core.html
@@ -7,6 +7,7 @@
<script type="text/javascript" src="../../../jquery-1.5.1.js"></script>
<script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script>
<script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script>
+ <script type="text/javascript" src="../../../ui/jquery.effects.core.js"></script>
<link rel="stylesheet" href="../../../external/qunit.css" type="text/css"/>
<script type="text/javascript" src="../../../external/qunit.js"></script>
@@ -14,6 +15,7 @@
<script type="text/javascript" src="../testsuite.js"></script>
<script type="text/javascript" src="core.js"></script>
+ <script type="text/javascript" src="core_tickets.js"></script>
<script type="text/javascript" src="selector.js"></script>
<script type="text/javascript" src="../swarminject.js"></script>
@@ -21,6 +23,7 @@
<style type="text/css">
.zindex {z-index: 100}
.absolute {position: absolute}
+ .ticket7106 {left: 100px}
</style>
</head>
<body>
@@ -128,6 +131,8 @@
<div id="zIndexAutoNoParent"></div>
<div id="dimensions" style="float: left; height: 50px; width: 100px; margin: 1px 12px 11px 2px; border-style: solid; border-width: 3px 14px 13px 4px; padding: 5px 16px 15px 6px;"></div>
+
+ <div id="ticket7106" style="left: 0px; opacity: 1;"></div>
</div>
</body>
diff --git a/tests/unit/core/core_tickets.js b/tests/unit/core/core_tickets.js
index e69de29..3ffc758 100644
--- a/tests/unit/core/core_tickets.js
+++ b/tests/unit/core/core_tickets.js
@@ -0,0 +1,15 @@
+/*
+ * core_tickets.js
+ */
+(function( $ ) {
+
+module( "core: tickets" );
+
+asyncTest( "#7106 - animateClass: css changed during animation is overwritten", function() {
+ $( "div#ticket7106" ).addClass( "ticket7106", 100, function() {
+ ok( $(this).css( "opacity" ) == "0.5" );
+ start();
+ } ).css( { opacity: "0.5" } );
+});
+
+}( jQuery ) );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment