r3412 committed - Effects: Fixed a bug when animating classes and nothing should happen,...

r3412 committed - Effects: Fixed a bug when animating classes and nothing should happen,...


Revision: 3412
Author: scott.gonzalez
Date: Fri Nov 6 06:15:53 2009
Log: Effects: Fixed a bug when animating classes and nothing should happen,
e.g., calling .removeClass('foo') when the element doesn't have the class
foo.
http://code.google.com/p/jquery-ui/source/detail?r=3412
Modified:
/trunk/ui/jquery.effects.core.js
=======================================
--- /trunk/ui/jquery.effects.core.js    Thu Nov 5 17:46:49 2009
+++ /trunk/ui/jquery.effects.core.js    Fri Nov 6 06:15:53 2009
@@ -103,22 +103,19 @@
            var that = $(this),
                originalStyleAttr = that.attr('style') || ' ',
                originalStyle = filterStyles(getElementStyles.call(this)),
-                newStyle;
-
-            $.each(classAnimationActions, function(action) {
+                newStyle,
+                className = that.attr('className');
+
+            $.each(classAnimationActions, function(i, action) {
                if (value[action]) {
                    that[action + 'Class'](value[action]);
                }
            });
            newStyle = filterStyles(getElementStyles.call(this));
-            $.each(classAnimationActions, function(action, reverse) {
-                if (value[action]) {
-                    that[reverse + 'Class'](value[action]);
-                }
-            });
+            that.attr('className', className);
            that.animate(styleDifference(originalStyle, newStyle), duration,
easing, function() {
-                $.each(classAnimationActions, function(action) {
+                $.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
@@ -136,11 +133,7 @@
// start class animations
-var classAnimationActions = {
-    add: 'remove',
-    remove: 'add',
-    toggle: 'toggle'
-};
+var classAnimationActions = ['add', 'remove', 'toggle'];
function getElementStyles() {
    var style = document.defaultView