mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
fix for #4374, gap in :hidden, :visible logic
This commit is contained in:
parent
62a251a0cf
commit
2c31a1624f
@ -969,7 +969,7 @@ jQuery.expr = Sizzle.selectors;
|
||||
jQuery.expr[":"] = jQuery.expr.filters;
|
||||
|
||||
Sizzle.selectors.filters.hidden = function(elem){
|
||||
return elem.offsetWidth === 0 || elem.offsetHeight === 0;
|
||||
return elem.offsetWidth === 0 && elem.offsetHeight === 0;
|
||||
};
|
||||
|
||||
Sizzle.selectors.filters.visible = function(elem){
|
||||
|
@ -311,7 +311,7 @@ test("attributes", function() {
|
||||
});
|
||||
|
||||
test("pseudo (:) selectors", function() {
|
||||
expect(70);
|
||||
expect(78);
|
||||
t( "First Child", "p:first-child", ["firstp","sndp"] );
|
||||
t( "Last Child", "p:last-child", ["sap"] );
|
||||
t( "Only Child", "a:only-child", ["simon1","anchor1","yahoo","anchor2","liveLink1","liveLink2"] );
|
||||
@ -363,6 +363,21 @@ test("pseudo (:) selectors", function() {
|
||||
t( "Is Hidden", "#main:hidden", ["main"] );
|
||||
t( "Is Hidden", "#dl:hidden", ["dl"] );
|
||||
|
||||
var $div = jQuery('#nothiddendivchild');
|
||||
$div.width(0).height(0);
|
||||
t( "Is Hidden", '#nothiddendivchild:hidden', ['nothiddendivchild'] );
|
||||
t( "Is Not Hidden", '#nothiddendivchild:visible', [] );
|
||||
$div.width(1).height(0);
|
||||
t( "Is Visible", '#nothiddendivchild:visible', ['nothiddendivchild'] );
|
||||
t( "Is Not Visible", '#nothiddendivchild:hidden', [] );
|
||||
$div.width(0).height(1);
|
||||
t( "Is Visible", '#nothiddendivchild:visible', ['nothiddendivchild'] );
|
||||
t( "Is Not Visible", '#nothiddendivchild:hidden', [] );
|
||||
$div.width(1).height(1);
|
||||
t( "Is Visible", '#nothiddendivchild:visible', ['nothiddendivchild'] );
|
||||
t( "Is Not Visible", '#nothiddendivchild:hidden', [] );
|
||||
$div.width('').height('');
|
||||
|
||||
t( "Check position filtering", "div#nothiddendiv:eq(0)", ["nothiddendiv"] );
|
||||
t( "Check position filtering", "div#nothiddendiv:last", ["nothiddendiv"] );
|
||||
t( "Check position filtering", "div#nothiddendiv:not(:gt(0))", ["nothiddendiv"] );
|
||||
|
Loading…
Reference in New Issue
Block a user