]> source.dussan.org Git - jquery.git/commitdiff
CSS: isHidden -> isHiddenWithinTree
authorTimmy Willison <timmywillisn@gmail.com>
Wed, 20 Jan 2016 18:20:58 +0000 (13:20 -0500)
committerTimmy Willison <timmywillisn@gmail.com>
Thu, 21 Jan 2016 16:27:39 +0000 (11:27 -0500)
Fixes gh-2404
Close gh-2855

src/css.js
src/css/showHide.js
src/css/var/isHidden.js [deleted file]
src/css/var/isHiddenWithinTree.js [new file with mode: 0644]
src/effects.js

index 5d3a0a6b598138cd451d5cfe5ae9f881ce97b267..f8bd8636aaa55683df2f3723a027c1111e0d52e4 100644 (file)
@@ -7,7 +7,6 @@ define( [
        "./var/rcssNum",
        "./css/var/rnumnonpx",
        "./css/var/cssExpand",
-       "./css/var/isHidden",
        "./css/var/getStyles",
        "./css/var/swap",
        "./css/curCSS",
@@ -19,7 +18,7 @@ define( [
        "./core/ready",
        "./selector" // contains
 ], function( jQuery, pnum, access, rmargin, document, rcssNum, rnumnonpx, cssExpand,
-       isHidden, getStyles, swap, curCSS, adjustCSS, addGetHookIf, support ) {
+       getStyles, swap, curCSS, adjustCSS, addGetHookIf, support ) {
 
 var
 
index 9e2cb1ea4a5dc88a39c0b66368ccc840d98fe53b..8c9b0da186cd47db46e4be35d21677a9982c2dee 100644 (file)
@@ -1,8 +1,8 @@
 define( [
        "../core",
        "../data/var/dataPriv",
-       "../css/var/isHidden"
-], function( jQuery, dataPriv, isHidden ) {
+       "../css/var/isHiddenWithinTree"
+], function( jQuery, dataPriv, isHiddenWithinTree ) {
 
 var defaultDisplayMap = {};
 
@@ -95,7 +95,7 @@ jQuery.fn.extend( {
                }
 
                return this.each( function() {
-                       if ( isHidden( this ) ) {
+                       if ( isHiddenWithinTree( this ) ) {
                                jQuery( this ).show();
                        } else {
                                jQuery( this ).hide();
diff --git a/src/css/var/isHidden.js b/src/css/var/isHidden.js
deleted file mode 100644 (file)
index 7997eff..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-define( [
-       "../../core",
-       "../../selector"
-
-       // css is assumed
-], function( jQuery ) {
-
-       return function( elem, el ) {
-
-               // isHidden might be called from jQuery#filter function;
-               // in that case, element will be second argument
-               elem = el || elem;
-               return jQuery.css( elem, "display" ) === "none" ||
-                       !jQuery.contains( elem.ownerDocument, elem );
-       };
-} );
diff --git a/src/css/var/isHiddenWithinTree.js b/src/css/var/isHiddenWithinTree.js
new file mode 100644 (file)
index 0000000..1c81f64
--- /dev/null
@@ -0,0 +1,18 @@
+define( [
+       "../../core",
+       "../../selector"
+
+       // css is assumed
+], function( jQuery ) {
+
+       // This function differs from the :hidden selector
+       // in that it intentionally ignores hidden ancestors (gh-2404)
+       return function( elem, el ) {
+
+               // isHiddenWithinTree might be called from jQuery#filter function;
+               // in that case, element will be second argument
+               elem = el || elem;
+               return jQuery.css( elem, "display" ) === "none" ||
+                       !jQuery.contains( elem.ownerDocument, elem );
+       };
+} );
index 43162e1fb885ad5db269454f3ea981e6e3b3e713..db4b4101caf6f0fa23b453c06f516a346faa278c 100644 (file)
@@ -4,7 +4,7 @@ define( [
        "./var/rcssNum",
        "./var/rnotwhite",
        "./css/var/cssExpand",
-       "./css/var/isHidden",
+       "./css/var/isHiddenWithinTree",
        "./css/var/swap",
        "./css/adjustCSS",
        "./data/var/dataPriv",
@@ -17,7 +17,7 @@ define( [
        "./manipulation",
        "./css",
        "./effects/Tween"
-], function( jQuery, document, rcssNum, rnotwhite, cssExpand, isHidden, swap,
+], function( jQuery, document, rcssNum, rnotwhite, cssExpand, isHiddenWithinTree, swap,
        adjustCSS, dataPriv, showHide ) {
 
 var
@@ -82,7 +82,7 @@ function defaultPrefilter( elem, props, opts ) {
                anim = this,
                orig = {},
                style = elem.style,
-               hidden = elem.nodeType && isHidden( elem ),
+               hidden = elem.nodeType && isHiddenWithinTree( elem ),
                dataShow = dataPriv.get( elem, "fxshow" );
 
        // Queue-skipping animations hijack the fx hooks
@@ -479,7 +479,7 @@ jQuery.fn.extend( {
        fadeTo: function( speed, to, easing, callback ) {
 
                // Show any hidden elements after setting opacity to 0
-               return this.filter( isHidden ).css( "opacity", 0 ).show()
+               return this.filter( isHiddenWithinTree ).css( "opacity", 0 ).show()
 
                        // Animate to the value specified
                        .end().animate( { opacity: to }, speed, easing, callback );