@@ -82,8 +82,6 @@ if (!DOMTokenList.prototype.remove) {
8282 "attr" ,
8383 "derive" ] ;
8484
85- var start = Date . now ( ) ;
86-
8785 var search_input = document . getElementsByClassName ( "search-input" ) [ 0 ] ;
8886
8987 // On the search screen, so you remain on the last tab you opened.
@@ -148,7 +146,7 @@ if (!DOMTokenList.prototype.remove) {
148146 var TY_PRIMITIVE = itemTypes . indexOf ( "primitive" ) ;
149147 var TY_KEYWORD = itemTypes . indexOf ( "keyword" ) ;
150148
151- onEach ( Array . prototype . slice . call ( document . getElementsByClassName ( "js-only" ) ) , function ( e ) {
149+ onEachLazy ( document . getElementsByClassName ( "js-only" ) , function ( e ) {
152150 removeClass ( e , "js-only" ) ;
153151 } ) ;
154152
@@ -190,9 +188,8 @@ if (!DOMTokenList.prototype.remove) {
190188 x . scrollIntoView ( ) ;
191189 }
192190 }
193- onEach ( Array . prototype . slice . call ( document . getElementsByClassName ( "line-numbers" ) ) ,
194- function ( e ) {
195- onEach ( Array . prototype . slice . call ( e . getElementsByTagName ( "span" ) ) , function ( i_e ) {
191+ onEachLazy ( document . getElementsByClassName ( "line-numbers" ) , function ( e ) {
192+ onEachLazy ( e . getElementsByTagName ( "span" ) , function ( i_e ) {
196193 removeClass ( i_e , "line-highlighted" ) ;
197194 } ) ;
198195 } ) ;
@@ -1103,7 +1100,7 @@ if (!DOMTokenList.prototype.remove) {
11031100 aliases [ i ] . displayPath = pathSplitter ( res [ 0 ] ) ;
11041101 aliases [ i ] . fullPath = aliases [ i ] . displayPath + aliases [ i ] . name ;
11051102 aliases [ i ] . href = res [ 1 ] ;
1106- retothers . unshift ( aliases [ i ] ) ;
1103+ ret . others . unshift ( aliases [ i ] ) ;
11071104 if ( ret . others . length > MAX_RESULTS ) {
11081105 ret . others . pop ( ) ;
11091106 }
@@ -1192,16 +1189,16 @@ if (!DOMTokenList.prototype.remove) {
11921189 }
11931190 clearTimeout ( hoverTimeout ) ;
11941191 hoverTimeout = setTimeout ( function ( ) {
1195- onEach ( document . getElementsByClassName ( "search-results" ) , function ( e ) {
1196- onEach ( e . getElementsByClassName ( "result" ) , function ( i_e ) {
1192+ onEachLazy ( document . getElementsByClassName ( "search-results" ) , function ( e ) {
1193+ onEachLazy ( e . getElementsByClassName ( "result" ) , function ( i_e ) {
11971194 removeClass ( i_e , "highlighted" ) ;
11981195 } ) ;
11991196 } ) ;
12001197 addClass ( el , "highlighted" ) ;
12011198 } , 20 ) ;
12021199 } ;
1203- onEach ( document . getElementsByClassName ( "search-results" ) , function ( e ) {
1204- onEach ( e . getElementsByClassName ( "result" ) , function ( i_e ) {
1200+ onEachLazy ( document . getElementsByClassName ( "search-results" ) , function ( e ) {
1201+ onEachLazy ( e . getElementsByClassName ( "result" ) , function ( i_e ) {
12051202 i_e . onclick = click_func ;
12061203 i_e . onmouseover = mouseover_func ;
12071204 } ) ;
@@ -1213,8 +1210,8 @@ if (!DOMTokenList.prototype.remove) {
12131210 var actives = [ [ ] , [ ] , [ ] ] ;
12141211 // "current" is used to know which tab we're looking into.
12151212 var current = 0 ;
1216- onEach ( document . getElementsByClassName ( "search-results" ) , function ( e ) {
1217- onEach ( e . getElementsByClassName ( "highlighted" ) , function ( e ) {
1213+ onEachLazy ( document . getElementsByClassName ( "search-results" ) , function ( e ) {
1214+ onEachLazy ( e . getElementsByClassName ( "highlighted" ) , function ( e ) {
12181215 actives [ current ] . push ( e ) ;
12191216 } ) ;
12201217 current += 1 ;
@@ -1418,7 +1415,7 @@ if (!DOMTokenList.prototype.remove) {
14181415 td_width = tds [ 0 ] . offsetWidth ;
14191416 }
14201417 var width = search . offsetWidth - 40 - td_width ;
1421- onEach ( Array . prototype . slice . call ( search . getElementsByClassName ( "desc" ) ) , function ( e ) {
1418+ onEachLazy ( search . getElementsByClassName ( "desc" ) , function ( e ) {
14221419 e . style . width = width + "px" ;
14231420 } ) ;
14241421 initSearchNav ( ) ;
@@ -1894,9 +1891,7 @@ if (!DOMTokenList.prototype.remove) {
18941891 } ) ;
18951892 innerToggle . title = "collapse all docs" ;
18961893 if ( fromAutoCollapse !== true ) {
1897- onEach ( Array . prototype . slice . call (
1898- document . getElementsByClassName ( "collapse-toggle" ) ) ,
1899- function ( e ) {
1894+ onEachLazy ( document . getElementsByClassName ( "collapse-toggle" ) , function ( e ) {
19001895 collapseDocs ( e , "show" ) ;
19011896 } ) ;
19021897 }
@@ -1908,9 +1903,7 @@ if (!DOMTokenList.prototype.remove) {
19081903 } ) ;
19091904 innerToggle . title = "expand all docs" ;
19101905 if ( fromAutoCollapse !== true ) {
1911- onEach ( Array . prototype . slice . call (
1912- document . getElementsByClassName ( "collapse-toggle" ) ) ,
1913- function ( e ) {
1906+ onEachLazy ( document . getElementsByClassName ( "collapse-toggle" ) , function ( e ) {
19141907 collapseDocs ( e , "hide" , pageId ) ;
19151908 } ) ;
19161909 }
@@ -1984,12 +1977,12 @@ if (!DOMTokenList.prototype.remove) {
19841977 }
19851978 if ( action === "hide" ) {
19861979 addClass ( relatedDoc , "hidden-by-usual-hider" ) ;
1987- onEach ( Array . prototype . slice . call ( toggle . childNodes ) , adjustToggle ( true ) ) ;
1980+ onEachLazy ( toggle . childNodes , adjustToggle ( true ) ) ;
19881981 addClass ( toggle . parentNode , "collapsed" ) ;
19891982 } else if ( action === "show" ) {
19901983 removeClass ( relatedDoc , "hidden-by-usual-hider" ) ;
19911984 removeClass ( toggle . parentNode , "collapsed" ) ;
1992- onEach ( Array . prototype . slice . call ( toggle . childNodes ) , adjustToggle ( false ) ) ;
1985+ onEachLazy ( toggle . childNodes , adjustToggle ( false ) ) ;
19931986 }
19941987 }
19951988 } else {
@@ -2022,13 +2015,13 @@ if (!DOMTokenList.prototype.remove) {
20222015 if ( action === "show" ) {
20232016 removeClass ( relatedDoc , "fns-now-collapsed" ) ;
20242017 removeClass ( docblock , "hidden-by-usual-hider" ) ;
2025- onEach ( Array . prototype . slice . call ( toggle . childNodes ) , adjustToggle ( false ) ) ;
2026- onEach ( Array . prototype . slice . call ( relatedDoc . childNodes ) , implHider ( false ) ) ;
2018+ onEachLazy ( toggle . childNodes , adjustToggle ( false ) ) ;
2019+ onEachLazy ( relatedDoc . childNodes , implHider ( false ) ) ;
20272020 } else if ( action === "hide" ) {
20282021 addClass ( relatedDoc , "fns-now-collapsed" ) ;
20292022 addClass ( docblock , "hidden-by-usual-hider" ) ;
2030- onEach ( Array . prototype . slice . call ( toggle . childNodes ) , adjustToggle ( true ) ) ;
2031- onEach ( Array . prototype . slice . call ( relatedDoc . childNodes ) , implHider ( true ) ) ;
2023+ onEachLazy ( toggle . childNodes , adjustToggle ( true ) ) ;
2024+ onEachLazy ( relatedDoc . childNodes , implHider ( true ) ) ;
20322025 }
20332026 }
20342027 }
@@ -2052,9 +2045,7 @@ if (!DOMTokenList.prototype.remove) {
20522045 var impl_list = document . getElementById ( "implementations-list" ) ;
20532046
20542047 if ( impl_list !== null ) {
2055- onEach ( Array . prototype . slice . call (
2056- impl_list . getElementsByClassName ( "collapse-toggle" ) ) ,
2057- collapser ) ;
2048+ onEachLazy ( impl_list . getElementsByClassName ( "collapse-toggle" ) , collapser ) ;
20582049 }
20592050 }
20602051 }
@@ -2104,9 +2095,9 @@ if (!DOMTokenList.prototype.remove) {
21042095 }
21052096 } ;
21062097
2107- onEach ( Array . prototype . slice . call ( document . getElementsByClassName ( "method" ) ) , func ) ;
2108- onEach ( Array . prototype . slice . call ( document . getElementsByClassName ( "associatedconstant" ) ) , func ) ;
2109- onEach ( Array . prototype . slice . call ( document . getElementsByClassName ( "impl" ) ) , funcImpl ) ;
2098+ onEachLazy ( document . getElementsByClassName ( "method" ) , func ) ;
2099+ onEachLazy ( document . getElementsByClassName ( "associatedconstant" ) , func ) ;
2100+ onEachLazy ( document . getElementsByClassName ( "impl" ) , funcImpl ) ;
21102101 var impl_call = function ( ) { } ;
21112102 if ( getCurrentValue ( "rustdoc-method-docs" ) !== "false" ) {
21122103 impl_call = function ( e , newToggle , pageId ) {
@@ -2127,8 +2118,7 @@ if (!DOMTokenList.prototype.remove) {
21272118 function toggleClicked ( ) {
21282119 if ( hasClass ( this , "collapsed" ) ) {
21292120 removeClass ( this , "collapsed" ) ;
2130- onEach ( Array . prototype . slice . call ( this . parentNode . getElementsByClassName ( "hidden" ) ) ,
2131- function ( x ) {
2121+ onEachLazy ( this . parentNode . getElementsByClassName ( "hidden" ) , function ( x ) {
21322122 if ( hasClass ( x , "content" ) === false ) {
21332123 removeClass ( x , "hidden" ) ;
21342124 addClass ( x , "x" ) ;
@@ -2138,8 +2128,7 @@ if (!DOMTokenList.prototype.remove) {
21382128 "</span>] Hide undocumented items" ;
21392129 } else {
21402130 addClass ( this , "collapsed" ) ;
2141- onEach ( Array . prototype . slice . call ( this . parentNode . getElementsByClassName ( "x" ) ) ,
2142- function ( x ) {
2131+ onEachLazy ( this . parentNode . getElementsByClassName ( "x" ) , function ( x ) {
21432132 if ( hasClass ( x , "content" ) === false ) {
21442133 addClass ( x , "hidden" ) ;
21452134 removeClass ( x , "x" ) ;
@@ -2149,8 +2138,8 @@ if (!DOMTokenList.prototype.remove) {
21492138 "</span>] Show hidden undocumented items" ;
21502139 }
21512140 }
2152- onEach ( Array . prototype . slice . call ( document . getElementsByClassName ( "impl-items" ) ) , function ( e ) {
2153- onEach ( Array . prototype . slice . call ( e . getElementsByClassName ( "associatedconstant" ) ) , func ) ;
2141+ onEachLazy ( document . getElementsByClassName ( "impl-items" ) , function ( e ) {
2142+ onEachLazy ( e . getElementsByClassName ( "associatedconstant" ) , func ) ;
21542143 var hiddenElems = e . getElementsByClassName ( "hidden" ) ;
21552144 var needToggle = false ;
21562145
@@ -2215,13 +2204,10 @@ if (!DOMTokenList.prototype.remove) {
22152204
22162205 e . style . display = "none" ;
22172206 addClass ( wrap , "collapsed" ) ;
2218- onEach ( Array . prototype . slice . call ( inner_toggle . getElementsByClassName ( "inner" ) ) ,
2219- function ( e ) {
2207+ onEachLazy ( inner_toggle . getElementsByClassName ( "inner" ) , function ( e ) {
22202208 e . innerHTML = labelForToggleButton ( true ) ;
22212209 } ) ;
2222- onEach ( Array . prototype . slice . call (
2223- inner_toggle . getElementsByClassName ( "toggle-label" ) ) ,
2224- function ( e ) {
2210+ onEachLazy ( inner_toggle . getElementsByClassName ( "toggle-label" ) , function ( e ) {
22252211 e . style . display = "inline-block" ;
22262212 if ( extra === true ) {
22272213 i_e . innerHTML = " Show " + e . childNodes [ 0 ] . innerHTML ;
@@ -2268,28 +2254,24 @@ if (!DOMTokenList.prototype.remove) {
22682254 }
22692255 }
22702256
2271- onEach ( Array . prototype . slice . call ( document . getElementsByClassName ( "docblock" ) ) ,
2272- buildToggleWrapper ) ;
2273- onEach ( Array . prototype . slice . call ( document . getElementsByClassName ( "sub-variant" ) ) ,
2274- buildToggleWrapper ) ;
2257+ onEachLazy ( document . getElementsByClassName ( "docblock" ) , buildToggleWrapper ) ;
2258+ onEachLazy ( document . getElementsByClassName ( "sub-variant" ) , buildToggleWrapper ) ;
22752259
22762260 // In the search display, allows to switch between tabs.
22772261 function printTab ( nb ) {
22782262 if ( nb === 0 || nb === 1 || nb === 2 ) {
22792263 currentTab = nb ;
22802264 }
22812265 var nb_copy = nb ;
2282- onEach ( Array . prototype . slice . call ( document . getElementById ( "titles" ) . childNodes ) ,
2283- function ( elem ) {
2266+ onEachLazy ( document . getElementById ( "titles" ) . childNodes , function ( elem ) {
22842267 if ( nb_copy === 0 ) {
22852268 addClass ( elem , "selected" ) ;
22862269 } else {
22872270 removeClass ( elem , "selected" ) ;
22882271 }
22892272 nb_copy -= 1 ;
22902273 } ) ;
2291- onEach ( Array . prototype . slice . call ( document . getElementById ( "results" ) . childNodes ) ,
2292- function ( elem ) {
2274+ onEachLazy ( document . getElementById ( "results" ) . childNodes , function ( elem ) {
22932275 if ( nb === 0 ) {
22942276 elem . style . display = "" ;
22952277 } else {
@@ -2320,7 +2302,7 @@ if (!DOMTokenList.prototype.remove) {
23202302 } ;
23212303 }
23222304 var attributesToggle = createToggleWrapper ( createSimpleToggle ( false ) ) ;
2323- onEach ( Array . prototype . slice . call ( main . getElementsByClassName ( "attributes" ) ) , function ( i_e ) {
2305+ onEachLazy ( main . getElementsByClassName ( "attributes" ) , function ( i_e ) {
23242306 i_e . parentNode . insertBefore ( attributesToggle . cloneNode ( true ) , i_e ) ;
23252307 itemAttributesFunc ( i_e ) ;
23262308 } ) ;
@@ -2340,8 +2322,7 @@ if (!DOMTokenList.prototype.remove) {
23402322 x . parentNode . insertBefore ( node , x ) ;
23412323 } ;
23422324 }
2343- onEach ( Array . prototype . slice . call ( document . getElementsByClassName ( "rust-example-rendered" ) ) ,
2344- function ( e ) {
2325+ onEachLazy ( document . getElementsByClassName ( "rust-example-rendered" ) , function ( e ) {
23452326 if ( hasClass ( e , "compile_fail" ) ) {
23462327 e . addEventListener ( "mouseover" , function ( event ) {
23472328 this . parentElement . previousElementSibling . childNodes [ 0 ] . style . color = "#f00" ;
@@ -2379,8 +2360,7 @@ if (!DOMTokenList.prototype.remove) {
23792360 }
23802361 }
23812362
2382- onEach ( Array . prototype . slice . call ( document . getElementsByClassName ( "important-traits" ) ) ,
2383- function ( e ) {
2363+ onEachLazy ( document . getElementsByClassName ( "important-traits" ) , function ( e ) {
23842364 e . onclick = function ( ) {
23852365 showModal ( e . lastElementChild . innerHTML ) ;
23862366 } ;
@@ -2435,7 +2415,7 @@ if (!DOMTokenList.prototype.remove) {
24352415 }
24362416
24372417 if ( main ) {
2438- onEach ( Array . prototype . slice . call ( main . childNodes ) , function ( e ) {
2418+ onEachLazy ( main . childNodes , function ( e ) {
24392419 if ( e . tagName === "H2" || e . tagName === "H3" ) {
24402420 e . nextElementSibling . style . display = "block" ;
24412421 }
0 commit comments