if ( parts ) {
var end = parseFloat( parts[2] ),
- unit = parts[3] || "px";
+ unit = parts[3] || ( jQuery.cssNumber[ name ] ? "" : "px" );
// We need to compute starting value
if ( unit !== "px" ) {
this.startTime = jQuery.now();
this.start = from;
this.end = to;
- this.unit = unit || this.unit || "px";
+ this.unit = unit || this.unit || ( jQuery.cssNumber[ this.prop ] ? "" : "px" );
this.now = this.start;
this.pos = this.state = 0;
}
function defaultDisplay( nodeName ) {
+ var stylesheets = document.styleSheets,
+ disabled = [],
+ elem, display, style, idx;
+
if ( !elemdisplay[ nodeName ] ) {
- var elem = jQuery("<" + nodeName + ">").appendTo("body"),
- display = elem.css("display");
+ // #8099 - If the end-dev has globally changed a default
+ // display, we can temporarily disable their styles to check
+ // for the correct default value
+ for ( idx = 0; idx < stylesheets.length; ++idx ) {
+ style = stylesheets[ idx ];
+ disabled[ idx ] = style.disabled;
+ style.disabled = true;
+ }
+
+ // To accurately check an element's default display value,
+ // create a temp element and check it's default display, this
+ // will ensure that the value returned is not a user-tampered
+ // value.
+ elem = jQuery("<" + nodeName + ">").appendTo("body"),
+ display = elem.css("display");
+
+ // Remove temp element
elem.remove();
if ( display === "none" || display === "" ) {
display = "block";
}
-
+
+ // Store the correct default display
elemdisplay[ nodeName ] = display;
+
+ // Restore stylesheets
+ for ( idx = 0; idx < stylesheets.length; ++idx ) {
+ stylesheets[ idx ].disabled = disabled[ idx ];
+ }
}
return elemdisplay[ nodeName ];
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" );
-// Supports #7397
+// Supports #7397
test("Persist correct display value", function() {
- expect(3);
+ expect(3);
QUnit.reset();
stop();
jQuery("#main").append('<div id="show-tests"><span style="position:absolute;">foo</span></div>');
var $span = jQuery("#show-tests span"),
- displayNone = $span.css("display"),
- display = '', num = 0;
-
- $span.show();
-
- display = $span.css("display");
+ displayNone = $span.css("display"),
+ display = '', num = 0;
- $span.hide();
+ $span.show();
- $span.fadeIn(100, function() {
+ display = $span.css("display");
- equals($span.css("display"), display, "Expecting display: " + display);
+ $span.hide();
- $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();
- });
- });
- });
+ $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("show() resolves correct default display #8099", function() {
+ expect(3);
+ var bug8099 = jQuery("<tt/>").appendTo("#main");
+
+ equals( bug8099.css("display"), "none", "default display override for all tt" );
+ equals( bug8099.show().css("display"), "inline", "Correctly resolves display:inline" );
+
+ bug8099.remove();
+
+ equals( jQuery("#foo").hide().show().css("display"), "block", "Correctly resolves display:block after hide/show" );
+ });
+
test("animate(Hash, Object, Function)", function() {
expect(1);
stop();
equals( fx.cur(), -11000, "Element has margin-bottom of -11000" );
delete jQuery.fx.step.marginBottom;
}
- });
+ });
jQuery("#main").css("marginBottom", "-11000px").animate({ marginBottom: "-11001px" }, {
duration: 1,
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);
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();
});
});
});
});
});
+
+test("animate unit-less properties (#4966)", 2, function() {
+ stop();
+ var div = jQuery( "<div style='z-index: 0; position: absolute;'></div>" ).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();
+ });
+});