Commit 8ea634fd authored by jeresig's avatar jeresig

Merge branch 'master' of github.com:jquery/jquery

parents f6ec9d54 2c28f229
...@@ -13,7 +13,7 @@ var elemdisplay = {}, ...@@ -13,7 +13,7 @@ var elemdisplay = {},
jQuery.fn.extend({ jQuery.fn.extend({
show: function( speed, callback ) { show: function( speed, callback ) {
if ( speed != null ) { if ( speed || speed === 0) {
return this.animate( genFx("show", 3), speed, callback); return this.animate( genFx("show", 3), speed, callback);
} else { } else {
...@@ -57,7 +57,7 @@ jQuery.fn.extend({ ...@@ -57,7 +57,7 @@ jQuery.fn.extend({
}, },
hide: function( speed, callback ) { hide: function( speed, callback ) {
if ( speed != null ) { if ( speed || speed === 0 ) {
return this.animate( genFx("hide", 3), speed, callback); return this.animate( genFx("hide", 3), speed, callback);
} else { } else {
......
...@@ -2,16 +2,16 @@ if ( "getBoundingClientRect" in document.documentElement ) { ...@@ -2,16 +2,16 @@ if ( "getBoundingClientRect" in document.documentElement ) {
jQuery.fn.offset = function( options ) { jQuery.fn.offset = function( options ) {
var elem = this[0]; var elem = this[0];
if ( !elem || !elem.ownerDocument ) {
return null;
}
if ( options ) { if ( options ) {
return this.each(function( i ) { return this.each(function( i ) {
jQuery.offset.setOffset( this, options, i ); jQuery.offset.setOffset( this, options, i );
}); });
} }
if ( !elem || !elem.ownerDocument ) {
return null;
}
if ( elem === elem.ownerDocument.body ) { if ( elem === elem.ownerDocument.body ) {
return jQuery.offset.bodyOffset( elem ); return jQuery.offset.bodyOffset( elem );
} }
...@@ -28,16 +28,16 @@ if ( "getBoundingClientRect" in document.documentElement ) { ...@@ -28,16 +28,16 @@ if ( "getBoundingClientRect" in document.documentElement ) {
jQuery.fn.offset = function( options ) { jQuery.fn.offset = function( options ) {
var elem = this[0]; var elem = this[0];
if ( !elem || !elem.ownerDocument ) {
return null;
}
if ( options ) { if ( options ) {
return this.each(function( i ) { return this.each(function( i ) {
jQuery.offset.setOffset( this, options, i ); jQuery.offset.setOffset( this, options, i );
}); });
} }
if ( !elem || !elem.ownerDocument ) {
return null;
}
if ( elem === elem.ownerDocument.body ) { if ( elem === elem.ownerDocument.body ) {
return jQuery.offset.bodyOffset( elem ); return jQuery.offset.bodyOffset( elem );
} }
......
module("effects"); module("effects");
test("show()", function() { test("show()", function() {
expect(16); expect(23);
var pass = true, div = jQuery("#main div"); var pass = true, div = jQuery("#main div");
div.show().each(function(){ div.show().each(function(){
if ( this.style.display == "none" ) pass = false; if ( this.style.display == "none" ) pass = false;
}); });
ok( pass, "Show" ); ok( pass, "Show" );
pass = true; var speeds = {
div.hide().show(null).each(function() { "null speed": null,
if ( this.style.display == "none" ) pass = false; "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);
});
jQuery.each(speeds, function(name, speed) {
pass = true;
div.hide().show(speed, function() {
pass = false;
});
ok( pass, "Show with " + name + " does not call animate callback" );
}); });
ok( pass, "Show will null speed");
jQuery("#main").append('<div id="show-tests"><div><p><a href="#"></a></p><code></code><pre></pre><span></span></div><table><thead><tr><th></th></tr></thead><tbody><tr><td></td></tr></tbody></table><ul><li></li></ul></div>'); jQuery("#main").append('<div id="show-tests"><div><p><a href="#"></a></p><code></code><pre></pre><span></span></div><table><thead><tr><th></th></tr></thead><tbody><tr><td></td></tr></tbody></table><ul><li></li></ul></div>');
......
...@@ -305,6 +305,13 @@ testoffset("body", function( jQuery ) { ...@@ -305,6 +305,13 @@ testoffset("body", function( jQuery ) {
equals( jQuery('body').offset().left, 1, "jQuery('#body').offset().left" ); equals( jQuery('body').offset().left, 1, "jQuery('#body').offset().left" );
}); });
test("Chaining offset(coords) returns jQuery object", function() {
expect(2);
var coords = { top: 1, left: 1 };
equals( jQuery("#absolute-1").offset(coords).selector, "#absolute-1", "offset(coords) returns jQuery object" );
equals( jQuery("#non-existent").offset(coords).selector, "#non-existent", "offset(coords) with empty jQuery set returns jQuery object" );
});
test("offsetParent", function(){ test("offsetParent", function(){
expect(11); expect(11);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment