Skip to content

Commit 60d4e0a

Browse files
committed
Class Animation: Use .attr( "class" ) instead of .attr( "className" ) and adjust the queueing logic for jQuery 1.6 compatibility. Fixes #7275 - $.effects.animateClass broken in jQuery 1.6."
1 parent cd61fb1 commit 60d4e0a

File tree

1 file changed

+24
-25
lines changed

1 file changed

+24
-25
lines changed

ui/jquery.effects.core.js

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -234,45 +234,44 @@ $.effects.animateClass = function( value, duration, easing, callback ) {
234234
easing = null;
235235
}
236236

237-
return this.queue( 'fx', function() {
237+
return this.queue(function() {
238238
var that = $( this ),
239239
originalStyleAttr = that.attr( 'style' ) || ' ',
240240
originalStyle = filterStyles( getElementStyles.call( this ) ),
241241
newStyle,
242-
className = that.attr( 'className' );
242+
className = that.attr( 'class' );
243243

244244
$.each( classAnimationActions, function(i, action) {
245245
if ( value[ action ] ) {
246246
that[ action + 'Class' ]( value[ action ] );
247247
}
248248
});
249249
newStyle = filterStyles( getElementStyles.call( this ) );
250-
that.attr( 'className', className );
251-
252-
that.animate( styleDifference( originalStyle, newStyle ), duration, easing, function() {
253-
$.each( classAnimationActions, function( i, action ) {
254-
if ( value[ action ] ) {
255-
that[ action + 'Class' ]( value[ action ] );
250+
that.attr( 'class', className );
251+
252+
that.animate( styleDifference( originalStyle, newStyle ), {
253+
queue: false,
254+
duration: duration,
255+
easing: easing,
256+
complete: function() {
257+
$.each( classAnimationActions, function( i, action ) {
258+
if ( value[ action ] ) {
259+
that[ action + 'Class' ]( value[ action ] );
260+
}
261+
});
262+
// work around bug in IE by clearing the cssText before setting it
263+
if ( typeof that.attr( 'style' ) == 'object' ) {
264+
that.attr( 'style' ).cssText = '';
265+
that.attr( 'style' ).cssText = originalStyleAttr;
266+
} else {
267+
that.attr( 'style', originalStyleAttr );
256268
}
257-
});
258-
// work around bug in IE by clearing the cssText before setting it
259-
if ( typeof that.attr( 'style' ) == 'object' ) {
260-
that.attr( 'style' ).cssText = '';
261-
that.attr( 'style' ).cssText = originalStyleAttr;
262-
} else {
263-
that.attr( 'style', originalStyleAttr );
264-
}
265-
if ( callback ) {
266-
callback.apply( this, arguments );
269+
if ( callback ) {
270+
callback.apply( this, arguments );
271+
}
272+
$.dequeue( this );
267273
}
268274
});
269-
270-
// $.animate adds a function to the end of the queue
271-
// but we want it at the front
272-
var queue = $.queue( this ),
273-
anim = queue.splice( queue.length - 1, 1 )[ 0 ];
274-
queue.splice( 1, 0, anim );
275-
$.dequeue( this );
276275
});
277276
};
278277

0 commit comments

Comments
 (0)