aboutsummaryrefslogtreecommitdiffstats
path: root/src/css.js
diff options
context:
space:
mode:
authorRichard Gibson <richard.gibson@gmail.com>2015-04-02 16:57:33 -0400
committerRichard Gibson <richard.gibson@gmail.com>2015-05-11 13:00:49 -0400
commit86419b10bfa5e3b71a7d416288ab806d47a31d1f (patch)
tree0e67bab0273e904df2f308ab26980291ec22adeb /src/css.js
parent5c3101fee60046fa7976b3131fada8dfe9fbd53e (diff)
downloadjquery-86419b10bfa5e3b71a7d416288ab806d47a31d1f.tar.gz
jquery-86419b10bfa5e3b71a7d416288ab806d47a31d1f.zip
CSS: Ignore the CSS cascade in show()/hide()/etc.
Fixes gh-1767 Fixes gh-2071 Closes gh-2180
Diffstat (limited to 'src/css.js')
-rw-r--r--src/css.js64
1 files changed, 2 insertions, 62 deletions
diff --git a/src/css.js b/src/css.js
index 286eef64b..7b011668e 100644
--- a/src/css.js
+++ b/src/css.js
@@ -11,16 +11,15 @@ define([
"./css/var/swap",
"./css/curCSS",
"./css/adjustCSS",
- "./css/defaultDisplay",
"./css/addGetHookIf",
"./css/support",
- "./data/var/dataPriv",
+ "./css/showHide",
"./core/init",
"./core/ready",
"./selector" // contains
], function( jQuery, pnum, access, rmargin, rcssNum, rnumnonpx, cssExpand, isHidden,
- getStyles, swap, curCSS, adjustCSS, defaultDisplay, addGetHookIf, support, dataPriv ) {
+ getStyles, swap, curCSS, adjustCSS, addGetHookIf, support, showHide ) {
var
// Swappable if display is none or starts with table
@@ -151,65 +150,6 @@ function getWidthOrHeight( elem, name, extra ) {
) + "px";
}
-function showHide( elements, show ) {
- var display, elem, hidden,
- values = [],
- index = 0,
- length = elements.length;
-
- for ( ; index < length; index++ ) {
- elem = elements[ index ];
- if ( !elem.style ) {
- continue;
- }
-
- values[ index ] = dataPriv.get( elem, "olddisplay" );
- display = elem.style.display;
- if ( show ) {
- // Reset the inline display of this element to learn if it is
- // being hidden by cascaded rules or not
- if ( !values[ index ] && display === "none" ) {
- elem.style.display = "";
- }
-
- // Set elements which have been overridden with display: none
- // in a stylesheet to whatever the default browser style is
- // for such an element
- if ( elem.style.display === "" && isHidden( elem ) ) {
- values[ index ] = dataPriv.access(
- elem,
- "olddisplay",
- defaultDisplay(elem.nodeName)
- );
- }
- } else {
- hidden = isHidden( elem );
-
- if ( display !== "none" || !hidden ) {
- dataPriv.set(
- elem,
- "olddisplay",
- hidden ? display : jQuery.css( elem, "display" )
- );
- }
- }
- }
-
- // Set the display of most of the elements in a second loop
- // to avoid the constant reflow
- for ( index = 0; index < length; index++ ) {
- elem = elements[ index ];
- if ( !elem.style ) {
- continue;
- }
- if ( !show || elem.style.display === "none" || elem.style.display === "" ) {
- elem.style.display = show ? values[ index ] || "" : "none";
- }
- }
-
- return elements;
-}
-
jQuery.extend({
// Add in style property hooks for overriding the default