Skip to content

Commit 9aadc26

Browse files
committed
Remove outdated visible/hidden detection from jQuery core from Selecting Elements article.
1 parent 83a8bca commit 9aadc26

File tree

1 file changed

+0
-37
lines changed

1 file changed

+0
-37
lines changed

page/using-jquery-core/selecting-elements.md

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -57,43 +57,6 @@ However, this test doesn't work with `<tr>` elements. In the case of `<tr>` jQue
5757

5858
Elements that have not been added to the DOM will always be considered hidden, even if the CSS that would affect them would render them visible. See the [Manipulating Elements](/manipulating-elements) section to learn how to create and add elements to the DOM.
5959

60-
For reference, here is the code jQuery uses to determine whether an element is visible or hidden:
61-
62-
```
63-
jQuery.expr.filters.hidden = function( elem ) {
64-
65-
var width = elem.offsetWidth;
66-
var height = elem.offsetHeight;
67-
var skip = elem.nodeName.toLowerCase() === "tr";
68-
69-
// does the element have 0 height, 0 width,
70-
// and it's not a <tr>?
71-
return width === 0 && height === 0 && !skip ?
72-
73-
// then it must be hidden
74-
true :
75-
76-
// but if it has width and height
77-
// and it's not a <tr>
78-
width > 0 && height > 0 && !skip ?
79-
80-
// then it must be visible
81-
false :
82-
83-
// if we get here, the element has width
84-
// and height, but it's also a <tr>,
85-
// so check its display property to
86-
// decide whether it's hidden
87-
jQuery.curCSS( elem, "display" ) === "none";
88-
};
89-
90-
jQuery.expr.filters.visible = function( elem ) {
91-
92-
return !jQuery.expr.filters.hidden( elem );
93-
94-
};
95-
```
96-
9760
## Choosing Selectors
9861

9962
Choosing good selectors is one way to improve JavaScript's performance. A little specificity &#8212; for example, including an element type when selecting elements by class name &#8212; can go a long way. On the other hand, too much specificity can be a bad thing. A selector such as `#myTable thead tr th.special` is overkill if a selector such as `#myTable th.special` will get the job done.

0 commit comments

Comments
 (0)