CSS: fix :visible/:hidden selectors for inline element w/ content

- Reverts behavior from 10399dd, which we never released.
  BR and inline elements are considered visible.
- The possibility of dropping .offsetWidth and .offsetHeight
  was debunked by this perf:
  http://jsperf.com/visible-hidden-and-getclientrects

Fixes gh-2227
Close gh-2281
This commit is contained in:
Timmy Willison
2015-05-08 15:27:54 -07:00
parent 7855a1a7d8
commit 79bcb29132
2 changed files with 15 additions and 11 deletions

View File

@@ -4,12 +4,10 @@ define([
], function( jQuery ) {
jQuery.expr.filters.hidden = function( elem ) {
// Use OR instead of AND as the element is not visible if either is true
// See tickets #10406 and #13132
return !elem.offsetWidth || !elem.offsetHeight;
return !jQuery.expr.filters.visible( elem );
};
jQuery.expr.filters.visible = function( elem ) {
return !jQuery.expr.filters.hidden( elem );
return !!( elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length );
};
});