MCPcopy Create free account
hub / github.com/HtmlUnit/htmlunit / showHide

Function showHide

src/test/resources/libraries/jQuery/1.11.3/jquery/src/css.js:67–116  ·  view source on GitHub ↗
( elements, show )

Source from the content-addressed store, hash-verified

65}
66
67function showHide( elements, show ) {
68 var display, elem, hidden,
69 values = [],
70 index = 0,
71 length = elements.length;
72
73 for ( ; index < length; index++ ) {
74 elem = elements[ index ];
75 if ( !elem.style ) {
76 continue;
77 }
78
79 values[ index ] = jQuery._data( elem, "olddisplay" );
80 display = elem.style.display;
81 if ( show ) {
82 // Reset the inline display of this element to learn if it is
83 // being hidden by cascaded rules or not
84 if ( !values[ index ] && display === "none" ) {
85 elem.style.display = "";
86 }
87
88 // Set elements which have been overridden with display: none
89 // in a stylesheet to whatever the default browser style is
90 // for such an element
91 if ( elem.style.display === "" && isHidden( elem ) ) {
92 values[ index ] = jQuery._data( elem, "olddisplay", defaultDisplay(elem.nodeName) );
93 }
94 } else {
95 hidden = isHidden( elem );
96
97 if ( display && display !== "none" || !hidden ) {
98 jQuery._data( elem, "olddisplay", hidden ? display : jQuery.css( elem, "display" ) );
99 }
100 }
101 }
102
103 // Set the display of most of the elements in a second loop
104 // to avoid the constant reflow
105 for ( index = 0; index < length; index++ ) {
106 elem = elements[ index ];
107 if ( !elem.style ) {
108 continue;
109 }
110 if ( !show || elem.style.display === "none" || elem.style.display === "" ) {
111 elem.style.display = show ? values[ index ] || "" : "none";
112 }
113 }
114
115 return elements;
116}
117
118function setPositiveNumber( elem, value, subtract ) {
119 var matches = rnumsplit.exec( value );

Callers 1

css.jsFile · 0.70

Calls 3

isHiddenFunction · 0.50
defaultDisplayFunction · 0.50
cssMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…