( elements, show )
| 6007 | } |
| 6008 | |
| 6009 | function showHide( elements, show ) { |
| 6010 | var display, elem, hidden, |
| 6011 | values = [], |
| 6012 | index = 0, |
| 6013 | length = elements.length; |
| 6014 | |
| 6015 | for ( ; index < length; index++ ) { |
| 6016 | elem = elements[ index ]; |
| 6017 | if ( !elem.style ) { |
| 6018 | continue; |
| 6019 | } |
| 6020 | |
| 6021 | values[ index ] = dataPriv.get( elem, "olddisplay" ); |
| 6022 | display = elem.style.display; |
| 6023 | if ( show ) { |
| 6024 | |
| 6025 | // Reset the inline display of this element to learn if it is |
| 6026 | // being hidden by cascaded rules or not |
| 6027 | if ( !values[ index ] && display === "none" ) { |
| 6028 | elem.style.display = ""; |
| 6029 | } |
| 6030 | |
| 6031 | // Set elements which have been overridden with display: none |
| 6032 | // in a stylesheet to whatever the default browser style is |
| 6033 | // for such an element |
| 6034 | if ( elem.style.display === "" && isHidden( elem ) ) { |
| 6035 | values[ index ] = dataPriv.access( |
| 6036 | elem, |
| 6037 | "olddisplay", |
| 6038 | defaultDisplay( elem.nodeName ) |
| 6039 | ); |
| 6040 | } |
| 6041 | } else { |
| 6042 | hidden = isHidden( elem ); |
| 6043 | |
| 6044 | if ( display !== "none" || !hidden ) { |
| 6045 | dataPriv.set( |
| 6046 | elem, |
| 6047 | "olddisplay", |
| 6048 | hidden ? display : jQuery.css( elem, "display" ) |
| 6049 | ); |
| 6050 | } |
| 6051 | } |
| 6052 | } |
| 6053 | |
| 6054 | // Set the display of most of the elements in a second loop |
| 6055 | // to avoid the constant reflow |
| 6056 | for ( index = 0; index < length; index++ ) { |
| 6057 | elem = elements[ index ]; |
| 6058 | if ( !elem.style ) { |
| 6059 | continue; |
| 6060 | } |
| 6061 | if ( !show || elem.style.display === "none" || elem.style.display === "" ) { |
| 6062 | elem.style.display = show ? values[ index ] || "" : "none"; |
| 6063 | } |
| 6064 | } |
| 6065 | |
| 6066 | return elements; |
no test coverage detected