fix for #4512 and minor sizzle updates

This commit is contained in:
Brandon Aaron 2009-06-23 18:11:09 +00:00
parent c6b9654ea8
commit de07ebc1a0

View file

@ -551,7 +551,7 @@ var Expr = Sizzle.selectors = {
} else if ( name === "not" ) { } else if ( name === "not" ) {
var not = match[3]; var not = match[3];
for ( i = 0, l = not.length; i < l; i++ ) { for ( var i = 0, l = not.length; i < l; i++ ) {
if ( not[i] === elem ) { if ( not[i] === elem ) {
return false; return false;
} }
@ -565,13 +565,13 @@ var Expr = Sizzle.selectors = {
switch (type) { switch (type) {
case 'only': case 'only':
case 'first': case 'first':
while ( (node = node.previousSibling) ) { while (node = node.previousSibling) {
if ( node.nodeType === 1 ) return false; if ( node.nodeType === 1 ) return false;
} }
if ( type == 'first') return true; if ( type == 'first') return true;
node = elem; node = elem;
case 'last': case 'last':
while ( (node = node.nextSibling) ) { while (node = node.nextSibling) {
if ( node.nodeType === 1 ) return false; if ( node.nodeType === 1 ) return false;
} }
return true; return true;
@ -977,21 +977,17 @@ 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){
var width = elem.offsetWidth, height = elem.offsetHeight; var width = elem.offsetWidth, height = elem.offsetHeight,
return ( width === 0 && height === 0 ) ? force = /^tr$/i.test( elem.tagName ); // ticket #4512
return ( width === 0 && height === 0 && !force ) ?
true : true :
( width !== 0 && height !== 0 ) ? ( width !== 0 && height !== 0 && !force ) ?
false : false :
!!( jQuery.curCSS(elem, "display") === "none" ); !!( jQuery.curCSS(elem, "display") === "none" );
}; };
Sizzle.selectors.filters.visible = function(elem){ Sizzle.selectors.filters.visible = function(elem){
var width = elem.offsetWidth, height = elem.offsetHeight; return !Sizzle.selectors.filters.hidden(elem);
return ( width === 0 && height === 0 ) ?
false :
( width > 0 && height > 0 ) ?
true :
!!( jQuery.curCSS(elem, "display") !== "none" );
}; };
Sizzle.selectors.filters.animated = function(elem){ Sizzle.selectors.filters.animated = function(elem){