diff options
author | Dave Methvin <dave.methvin@gmail.com> | 2012-07-25 21:24:49 -0400 |
---|---|---|
committer | Dave Methvin <dave.methvin@gmail.com> | 2012-07-25 21:24:49 -0400 |
commit | ed898c62c8d3e8c2091592976c181ee4142287ac (patch) | |
tree | fdd39a0023e6a7be39fe26b744644691c0db186e /src/css.js | |
parent | 5119b252ac2f3391e9f23efef4852095e0d7e6b3 (diff) | |
download | jquery-ed898c62c8d3e8c2091592976c181ee4142287ac.tar.gz jquery-ed898c62c8d3e8c2091592976c181ee4142287ac.zip |
Fix #12148. Let .toggle() call the public .hide() for punching.
There is a slightly shorter way to do this but it's not Closure-friendly.
Diffstat (limited to 'src/css.js')
-rw-r--r-- | src/css.js | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/css.js b/src/css.js index 57edd1507..744e7a545 100644 --- a/src/css.js +++ b/src/css.js @@ -43,8 +43,7 @@ function vendorPropName( style, name ) { return origName; } -function isHidden( elem, el ) { - elem = el || elem; +function isHidden( elem ) { return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument.documentElement, elem ); } @@ -111,16 +110,19 @@ jQuery.fn.extend({ hide: function() { return showHide( this ); }, - toggle: function( fn, fn2 ) { - var bool = typeof fn === "boolean"; + toggle: function( state, fn2 ) { + var bool = typeof state === "boolean"; - if ( jQuery.isFunction( fn ) && jQuery.isFunction( fn2 ) ) { + if ( jQuery.isFunction( state ) && jQuery.isFunction( fn2 ) ) { return eventsToggle.apply( this, arguments ); } return this.each(function() { - var state = bool ? fn : jQuery( this ).is(":hidden"); - showHide([ this ], state ); + if ( bool ? state : isHidden( this ) ) { + jQuery( this ).show(); + } else { + jQuery( this ).hide(); + } }); } }); |