mirror of
https://github.com/jquery/jquery.git
synced 2026-02-01 04:24:58 -05:00
CSS: Make show/hide/toggle methods a module
Unit test changes some uses of .show() and .hide() to .css( "display", ... ), there was already an implicit assumption in several of the existing tests. Fixes gh-2193 Close gh-2648
This commit is contained in:
committed by
Timmy Willison
parent
e271f665dd
commit
67d7a2eefe
@@ -1,6 +1,7 @@
|
||||
define( [
|
||||
"../data/var/dataPriv"
|
||||
], function( dataPriv ) {
|
||||
"../data/var/dataPriv",
|
||||
"../css/var/isHidden"
|
||||
], function( dataPriv, isHidden ) {
|
||||
|
||||
function showHide( elements, show ) {
|
||||
var display, elem,
|
||||
@@ -43,6 +44,26 @@ function showHide( elements, show ) {
|
||||
return elements;
|
||||
}
|
||||
|
||||
return showHide;
|
||||
jQuery.fn.extend( {
|
||||
show: function() {
|
||||
return showHide( this, true );
|
||||
},
|
||||
hide: function() {
|
||||
return showHide( this );
|
||||
},
|
||||
toggle: function( state ) {
|
||||
if ( typeof state === "boolean" ) {
|
||||
return state ? this.show() : this.hide();
|
||||
}
|
||||
|
||||
return this.each( function() {
|
||||
if ( isHidden( this ) ) {
|
||||
jQuery( this ).show();
|
||||
} else {
|
||||
jQuery( this ).hide();
|
||||
}
|
||||
} );
|
||||
}
|
||||
} );
|
||||
|
||||
} );
|
||||
|
||||
Reference in New Issue
Block a user