Change the behavior of how :visible and :hidden work. :hidden is when an element is display none, a parent element is display none, or the element has a width of 0. :visible is when the element is not display none and all of its ancesotrs are not display none and its width is larger than 0. Fixes jQuery bugs #1349, #3265, and #3895.
This commit is contained in:
parent
5586fedf29
commit
e25c4a132f
|
@ -937,15 +937,11 @@ jQuery.expr = Sizzle.selectors;
|
||||||
jQuery.expr[":"] = jQuery.expr.filters;
|
jQuery.expr[":"] = jQuery.expr.filters;
|
||||||
|
|
||||||
Sizzle.selectors.filters.hidden = function(elem){
|
Sizzle.selectors.filters.hidden = function(elem){
|
||||||
return "hidden" === elem.type ||
|
return elem.offsetWidth === 0;
|
||||||
jQuery.css(elem, "display") === "none" ||
|
|
||||||
jQuery.css(elem, "visibility") === "hidden";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Sizzle.selectors.filters.visible = function(elem){
|
Sizzle.selectors.filters.visible = function(elem){
|
||||||
return "hidden" !== elem.type &&
|
return elem.offsetWidth > 0;
|
||||||
jQuery.css(elem, "display") !== "none" &&
|
|
||||||
jQuery.css(elem, "visibility") !== "hidden";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Sizzle.selectors.filters.animated = function(elem){
|
Sizzle.selectors.filters.animated = function(elem){
|
||||||
|
|
|
@ -308,7 +308,7 @@ test("attributes", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test("pseudo (:) selectors", function() {
|
test("pseudo (:) selectors", function() {
|
||||||
expect(67);
|
expect(70);
|
||||||
t( "First Child", "p:first-child", ["firstp","sndp"] );
|
t( "First Child", "p:first-child", ["firstp","sndp"] );
|
||||||
t( "Last Child", "p:last-child", ["sap"] );
|
t( "Last Child", "p:last-child", ["sap"] );
|
||||||
t( "Only Child", "a:only-child", ["simon1","anchor1","yahoo","anchor2","liveLink1","liveLink2"] );
|
t( "Only Child", "a:only-child", ["simon1","anchor1","yahoo","anchor2","liveLink1","liveLink2"] );
|
||||||
|
@ -354,8 +354,11 @@ test("pseudo (:) selectors", function() {
|
||||||
t( "Position Greater Than", "p:gt(0)", ["ap","sndp","en","sap","first"] );
|
t( "Position Greater Than", "p:gt(0)", ["ap","sndp","en","sap","first"] );
|
||||||
t( "Position Less Than", "p:lt(3)", ["firstp","ap","sndp"] );
|
t( "Position Less Than", "p:lt(3)", ["firstp","ap","sndp"] );
|
||||||
t( "Is A Parent", "p:parent", ["firstp","ap","sndp","en","sap","first"] );
|
t( "Is A Parent", "p:parent", ["firstp","ap","sndp","en","sap","first"] );
|
||||||
t( "Is Visible", "#form input:visible", ["text1","text2","radio1","radio2","check1","check2","name"] );
|
t( "Is Visible", "#form input:visible", [] );
|
||||||
t( "Is Hidden", "#form input:hidden", ["hidden1","hidden2"] );
|
t( "Is Visible", "div:visible:not(.testrunner-toolbar)", ["nothiddendiv", "nothiddendivchild"] );
|
||||||
|
t( "Is Hidden", "#form input:hidden", ["text1","text2","radio1","radio2","check1","check2","hidden1","hidden2","name"] );
|
||||||
|
t( "Is Hidden", "#main:hidden", ["main"] );
|
||||||
|
t( "Is Hidden", "#dl:hidden", ["dl"] );
|
||||||
|
|
||||||
t( "Check position filtering", "div#nothiddendiv:eq(0)", ["nothiddendiv"] );
|
t( "Check position filtering", "div#nothiddendiv:eq(0)", ["nothiddendiv"] );
|
||||||
t( "Check position filtering", "div#nothiddendiv:last", ["nothiddendiv"] );
|
t( "Check position filtering", "div#nothiddendiv:last", ["nothiddendiv"] );
|
||||||
|
|
Loading…
Reference in a new issue