jQuery.css() returns a string value - handle this properly in the animation code.
authorJohn Resig <jeresig@gmail.com>
Fri, 17 Sep 2010 18:30:30 +0000 (14:30 -0400)
committerJohn Resig <jeresig@gmail.com>
Fri, 17 Sep 2010 18:30:30 +0000 (14:30 -0400)
src/effects.js
test/unit/effects.js

index eeab9b7..9c8abe5 100644 (file)
@@ -321,7 +321,7 @@ jQuery.fx.prototype = {
                        return this.elem[ this.prop ];
                }
 
-               var r = jQuery.css( this.elem, this.prop );
+               var r = parseFloat( jQuery.css( this.elem, this.prop ), 10 );
                return r && r > -10000 ? r : 0;
        },
 
index 32ce583..5ac4711 100644 (file)
@@ -240,11 +240,11 @@ test("stop()", function() {
        $foo.animate({ width:'show' }, 1000);
        setTimeout(function(){
                var nw = $foo.width();
-               ok( nw != w, "An animation occurred " + nw + "px " + w + "px");
+               notEqual( nw, w, "An animation occurred " + nw + "px " + w + "px");
                $foo.stop();
 
                nw = $foo.width();
-               ok( nw != w, "Stop didn't reset the animation " + nw + "px " + w + "px");
+               notEqual( nw, w, "Stop didn't reset the animation " + nw + "px " + w + "px");
                setTimeout(function(){
                        equals( nw, $foo.width(), "The animation didn't continue" );
                        start();
@@ -266,13 +266,12 @@ test("stop() - several in queue", function() {
        setTimeout(function(){
                equals( $foo.queue().length, 3, "All 3 still in the queue" );
                var nw = $foo.width();
-               ok( nw != w, "An animation occurred " + nw + "px " + w + "px");
+               notEqual( nw, w, "An animation occurred " + nw + "px " + w + "px");
                $foo.stop();
 
                nw = $foo.width();
-               ok( nw != w, "Stop didn't reset the animation " + nw + "px " + w + "px");
-               // Disabled, being flaky
-               //equals( $foo.queue().length, 1, "The next animation continued" );
+               notEqual( nw, w, "Stop didn't reset the animation " + nw + "px " + w + "px");
+
                $foo.stop(true);
                start();
        }, 100);
@@ -517,7 +516,7 @@ jQuery.each( {
                                if ( t_h == "show" ) {
                                        var old_h = jQuery.css(this, "height");
                                        jQuery(this).append("<br/>Some more text<br/>and some more...");
-                                       notEqual(jQuery.css(this, "height"), old_h, "Make sure height is auto.");
+                                       notEqual(jQuery.css(this, "height") + "px", old_h, "Make sure height is auto.");
                                }
        
                                start();