").hide().appendTo("#main").show();
equal( div.css("display"), "block", "Make sure pre-hidden divs show" );
@@ -39,24 +39,23 @@ test("show()", function() {
ok( pass, "Show" );
var speeds = {
- "null speed": null,
- "undefined speed": undefined,
- "empty string speed": "",
- "false speed": false
+ "null speed": null,
+ "undefined speed": undefined,
+ "empty string speed": "",
+ "false speed": false
};
jQuery.each(speeds, function(name, speed) {
- pass = true;
- div.hide().show(speed).each(function() {
- if ( this.style.display == "none" ) pass = false;
- });
- ok( pass, "Show with " + name);
- });
-
+ pass = true;
+ div.hide().show(speed).each(function() {
+ if ( this.style.display == "none" ) pass = false;
+ });
+ ok( pass, "Show with " + name);
+ });
jQuery.each(speeds, function(name, speed) {
- pass = true;
- div.hide().show(speed, function() {
+ pass = true;
+ div.hide().show(speed, function() {
pass = false;
});
ok( pass, "Show with " + name + " does not call animate callback" );
@@ -132,9 +131,9 @@ test("show(Number) - other displays", function() {
-// Supports #7397
+// Supports #7397
test("Persist correct display value", function() {
- expect(3);
+ expect(3);
QUnit.reset();
stop();
@@ -142,31 +141,25 @@ test("Persist correct display value", function() {
jQuery("#main").append('
foo
');
var $span = jQuery("#show-tests span"),
- displayNone = $span.css("display"),
- display = '', num = 0;
-
- $span.show();
-
- display = $span.css("display");
-
- $span.hide();
-
- $span.fadeIn(100, function() {
-
- equals($span.css("display"), display, "Expecting display: " + display);
-
- $span.fadeOut(100, function () {
+ displayNone = $span.css("display"),
+ display = '', num = 0;
- equals($span.css("display"), displayNone, "Expecting display: " + displayNone);
+ $span.show();
- $span.fadeIn(100, function() {
+ display = $span.css("display");
- equals($span.css("display"), display, "Expecting display: " + display);
+ $span.hide();
- start();
- });
- });
- });
+ $span.fadeIn(100, function() {
+ equals($span.css("display"), display, "Expecting display: " + display);
+ $span.fadeOut(100, function () {
+ equals($span.css("display"), displayNone, "Expecting display: " + displayNone);
+ $span.fadeIn(100, function() {
+ equals($span.css("display"), display, "Expecting display: " + display);
+ start();
+ });
+ });
+ });
});
test("animate(Hash, Object, Function)", function() {
@@ -403,13 +396,16 @@ test("animate duration 0", function() {
$elem.hide(0, function(){
ok(true, "Hide callback with no duration");
});
+
+ // manually clean up detached elements
+ $elem.remove();
});
test("animate hyphenated properties", function(){
expect(1);
stop();
- jQuery("#nothiddendiv")
+ jQuery("#foo")
.css("font-size", 10)
.animate({"font-size": 20}, 200, function(){
equals( this.style.fontSize, "20px", "The font-size property was animated." );
@@ -433,7 +429,7 @@ test("stop()", function() {
expect(3);
stop();
- var $foo = jQuery("#nothiddendiv");
+ var $foo = jQuery("#foo");
var w = 0;
$foo.hide().width(200).width();
@@ -446,6 +442,8 @@ test("stop()", function() {
nw = $foo.width();
notEqual( nw, w, "Stop didn't reset the animation " + nw + "px " + w + "px");
setTimeout(function(){
+ $foo.removeData();
+ $foo.removeData(undefined, true);
equals( nw, $foo.width(), "The animation didn't continue" );
start();
}, 100);
@@ -456,7 +454,7 @@ test("stop() - several in queue", function() {
expect(3);
stop();
- var $foo = jQuery("#nothiddendivchild");
+ var $foo = jQuery("#foo");
var w = 0;
$foo.hide().width(200).width();
@@ -481,7 +479,7 @@ test("stop(clearQueue)", function() {
expect(4);
stop();
- var $foo = jQuery("#nothiddendiv");
+ var $foo = jQuery("#foo");
var w = 0;
$foo.hide().width(200).width();
@@ -508,7 +506,7 @@ test("stop(clearQueue, gotoEnd)", function() {
expect(1);
stop();
- var $foo = jQuery("#nothiddendivchild");
+ var $foo = jQuery("#foo");
var w = 0;
$foo.hide().width(200).width();
@@ -536,7 +534,7 @@ test("stop(clearQueue, gotoEnd)", function() {
test("toggle()", function() {
expect(6);
- var x = jQuery("#nothiddendiv");
+ var x = jQuery("#foo");
ok( x.is(":visible"), "is visible" );
x.toggle();
ok( x.is(":hidden"), "is hidden" );
@@ -560,6 +558,56 @@ jQuery.checkOverflowDisplay = function(){
start();
}
+test( "jQuery.fx.prototype.cur()", 6, function() {
+ var div = jQuery( "
" ).appendTo( "#main" ).css({
+ color: "#ABC",
+ border: "5px solid black",
+ left: "auto",
+ marginBottom: "-11000px"
+ })[0];
+
+ equals(
+ ( new jQuery.fx( div, {}, "color" ) ).cur(),
+ jQuery.css( div, "color" ),
+ "Return the same value as jQuery.css for complex properties (bug #7912)"
+ );
+
+ strictEqual(
+ ( new jQuery.fx( div, {}, "borderLeftWidth" ) ).cur(),
+ 5,
+ "Return simple values parsed as Float"
+ );
+
+ // backgroundPosition actually returns 0% 0% in most browser
+ // this fakes a "" return
+ jQuery.cssHooks.backgroundPosition = {
+ get: function() {
+ ok( true, "hook used" );
+ return "";
+ }
+ };
+
+ strictEqual(
+ ( new jQuery.fx( div, {}, "backgroundPosition" ) ).cur(),
+ 0,
+ "Return 0 when jQuery.css returns an empty string"
+ );
+
+ delete jQuery.cssHooks.backgroundPosition;
+
+ strictEqual(
+ ( new jQuery.fx( div, {}, "left" ) ).cur(),
+ 0,
+ "Return 0 when jQuery.css returns 'auto'"
+ );
+
+ equals(
+ ( new jQuery.fx( div, {}, "marginBottom" ) ).cur(),
+ -11000,
+ "support negative values < -10000 (bug #7193)"
+ );
+});
+
test("JS Overflow and Display", function() {
expect(2);
stop();
@@ -720,6 +768,9 @@ jQuery.each( {
}
}
+ // manually remove generated element
+ jQuery(this).remove();
+
start();
});
});
@@ -746,6 +797,10 @@ jQuery.checkState = function(){
var cur = self.style[ c ] || jQuery.css(self, c);
equals( cur, v, "Make sure that " + c + " is reset (Old: " + v + " Cur: " + cur + ")");
});
+
+ // manually clean data on modified element
+ jQuery.removeData(this, 'olddisplay', true);
+
start();
}
@@ -774,7 +829,7 @@ test("Chain toggle out", function() {
jQuery('#toggleout div').saveState(jQuery.support.shrinkWrapBlocks).toggle('fast').toggle('fast',jQuery.checkState);
});
test("Chain toggle out with easing and callback", function() {
- jQuery('#toggleout div').saveState(jQuery.support.shrinkWrapBlocks).toggle('fast').toggle('fast','linear',jQuery.checkState);
+ jQuery('#toggleout div').saveState(jQuery.support.shrinkWrapBlocks).toggle('fast').toggle('fast','linear',jQuery.checkState);
});
test("Chain slideDown slideUp", function() {
jQuery('#slidedown div').saveState(jQuery.support.shrinkWrapBlocks).slideDown('fast').slideUp('fast',jQuery.checkState);
@@ -812,9 +867,6 @@ jQuery.makeTest = function( text ){
jQuery("
")
.text( text )
.appendTo("#fx-tests")
- .click(function(){
- jQuery(this).next().toggle();
- })
.after( elem );
return elem;
@@ -824,16 +876,16 @@ jQuery.makeTest.id = 1;
test("jQuery.show('fast') doesn't clear radio buttons (bug #1095)", function () {
expect(4);
- stop();
+ stop();
var $checkedtest = jQuery("#checkedtest");
// IE6 was clearing "checked" in jQuery(elem).show("fast");
$checkedtest.hide().show("fast", function() {
- ok( !! jQuery(":radio:first", $checkedtest).attr("checked"), "Check first radio still checked." );
- ok( ! jQuery(":radio:last", $checkedtest).attr("checked"), "Check last radio still NOT checked." );
- ok( !! jQuery(":checkbox:first", $checkedtest).attr("checked"), "Check first checkbox still checked." );
- ok( ! jQuery(":checkbox:last", $checkedtest).attr("checked"), "Check last checkbox still NOT checked." );
- start();
+ ok( !! jQuery(":radio:first", $checkedtest).attr("checked"), "Check first radio still checked." );
+ ok( ! jQuery(":radio:last", $checkedtest).attr("checked"), "Check last radio still NOT checked." );
+ ok( !! jQuery(":checkbox:first", $checkedtest).attr("checked"), "Check first checkbox still checked." );
+ ok( ! jQuery(":checkbox:last", $checkedtest).attr("checked"), "Check last checkbox still NOT checked." );
+ start();
});
});
@@ -878,7 +930,7 @@ test("hide hidden elements (bug #7141)", function() {
var div = jQuery("
").appendTo("#main");
equals( div.css("display"), "none", "Element is hidden by default" );
div.hide();
- ok( !div.data("olddisplay"), "olddisplay is undefined after hiding an already-hidden element" );
+ ok( !jQuery._data(div, "olddisplay"), "olddisplay is undefined after hiding an already-hidden element" );
div.show();
equals( div.css("display"), "block", "Show a double-hidden element" );
@@ -893,10 +945,20 @@ test("hide hidden elements, with animation (bug #7141)", function() {
var div = jQuery("
").appendTo("#main");
equals( div.css("display"), "none", "Element is hidden by default" );
div.hide(1, function () {
- ok( !div.data("olddisplay"), "olddisplay is undefined after hiding an already-hidden element" );
+ ok( !jQuery._data(div, "olddisplay"), "olddisplay is undefined after hiding an already-hidden element" );
div.show(1, function () {
equals( div.css("display"), "block", "Show a double-hidden element" );
start();
});
});
});
+
+test("animate unit-less properties (#4966)", 2, function() {
+ stop();
+ var div = jQuery( "
" ).appendTo( "#main" );
+ equal( div.css( "z-index" ), "0", "z-index is 0" );
+ div.animate({ zIndex: 2 }, function() {
+ equal( div.css( "z-index" ), "2", "z-index is 2" );
+ start();
+ });
+});