@@ -148,12 +148,10 @@ if (!DOMTokenList.prototype.remove) {
148
148
var TY_PRIMITIVE = itemTypes . indexOf ( "primitive" ) ;
149
149
var TY_KEYWORD = itemTypes . indexOf ( "keyword" ) ;
150
150
151
- onEach ( document . getElementsByClassName ( "js-only" ) , function ( e ) {
151
+ onEach ( Array . prototype . slice . call ( document . getElementsByClassName ( "js-only" ) ) , function ( e ) {
152
152
removeClass ( e , "js-only" ) ;
153
153
} ) ;
154
154
155
- console . log ( '1' , Date . now ( ) - start ) ;
156
-
157
155
function getQueryStringParams ( ) {
158
156
var params = { } ;
159
157
window . location . search . substring ( 1 ) . split ( "&" ) .
@@ -170,6 +168,8 @@ if (!DOMTokenList.prototype.remove) {
170
168
window . history && typeof window . history . pushState === "function" ;
171
169
}
172
170
171
+ var main = document . getElementById ( "main" ) ;
172
+
173
173
function highlightSourceLines ( ev ) {
174
174
// If we're in mobile mode, we should add the sidebar in any case.
175
175
hideSidebar ( ) ;
@@ -190,8 +190,9 @@ if (!DOMTokenList.prototype.remove) {
190
190
x . scrollIntoView ( ) ;
191
191
}
192
192
}
193
- onEach ( document . getElementsByClassName ( "line-numbers" ) , function ( e ) {
194
- onEach ( e . getElementsByTagName ( "span" ) , function ( i_e ) {
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 ) {
195
196
removeClass ( i_e , "line-highlighted" ) ;
196
197
} ) ;
197
198
} ) ;
@@ -200,7 +201,7 @@ if (!DOMTokenList.prototype.remove) {
200
201
}
201
202
} else if ( ev !== null && search && ! hasClass ( search , "hidden" ) && ev . newURL ) {
202
203
addClass ( search , "hidden" ) ;
203
- removeClass ( document . getElementById ( " main" ) , "hidden" ) ;
204
+ removeClass ( main , "hidden" ) ;
204
205
var hash = ev . newURL . slice ( ev . newURL . indexOf ( "#" ) + 1 ) ;
205
206
if ( browserSupportsHistoryApi ( ) ) {
206
207
history . replaceState ( hash , "" , "?search=#" + hash ) ;
@@ -233,8 +234,6 @@ if (!DOMTokenList.prototype.remove) {
233
234
highlightSourceLines ( null ) ;
234
235
window . onhashchange = highlightSourceLines ;
235
236
236
- console . log ( '2' , Date . now ( ) - start ) ;
237
-
238
237
// Gets the human-readable string for the virtual-key code of the
239
238
// given KeyboardEvent, ev.
240
239
//
@@ -279,7 +278,7 @@ if (!DOMTokenList.prototype.remove) {
279
278
} else if ( hasClass ( search , "hidden" ) === false ) {
280
279
ev . preventDefault ( ) ;
281
280
addClass ( search , "hidden" ) ;
282
- removeClass ( document . getElementById ( " main" ) , "hidden" ) ;
281
+ removeClass ( main , "hidden" ) ;
283
282
document . title = titleBeforeSearch ;
284
283
}
285
284
defocusSearchBar ( ) ;
@@ -407,8 +406,6 @@ if (!DOMTokenList.prototype.remove) {
407
406
} ;
408
407
}
409
408
410
- console . log ( '3' , Date . now ( ) - start ) ;
411
-
412
409
/**
413
410
* A function to compute the Levenshtein distance between two strings
414
411
* Licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported
@@ -1183,7 +1180,7 @@ if (!DOMTokenList.prototype.remove) {
1183
1180
dst = dst [ 0 ] ;
1184
1181
if ( window . location . pathname === dst . pathname ) {
1185
1182
addClass ( document . getElementById ( "search" ) , "hidden" ) ;
1186
- removeClass ( document . getElementById ( " main" ) , "hidden" ) ;
1183
+ removeClass ( main , "hidden" ) ;
1187
1184
document . location . href = dst . href ;
1188
1185
}
1189
1186
} ;
@@ -1411,7 +1408,7 @@ if (!DOMTokenList.prototype.remove) {
1411
1408
"</div><div id=\"results\">" +
1412
1409
ret_others [ 0 ] + ret_in_args [ 0 ] + ret_returned [ 0 ] + "</div>" ;
1413
1410
1414
- addClass ( document . getElementById ( " main" ) , "hidden" ) ;
1411
+ addClass ( main , "hidden" ) ;
1415
1412
var search = document . getElementById ( "search" ) ;
1416
1413
removeClass ( search , "hidden" ) ;
1417
1414
search . innerHTML = output ;
@@ -1421,7 +1418,7 @@ if (!DOMTokenList.prototype.remove) {
1421
1418
td_width = tds [ 0 ] . offsetWidth ;
1422
1419
}
1423
1420
var width = search . offsetWidth - 40 - td_width ;
1424
- onEach ( search . getElementsByClassName ( "desc" ) , function ( e ) {
1421
+ onEach ( Array . prototype . slice . call ( search . getElementsByClassName ( "desc" ) ) , function ( e ) {
1425
1422
e . style . width = width + "px" ;
1426
1423
} ) ;
1427
1424
initSearchNav ( ) ;
@@ -1619,7 +1616,6 @@ if (!DOMTokenList.prototype.remove) {
1619
1616
if ( browserSupportsHistoryApi ( ) ) {
1620
1617
history . replaceState ( "" , "std - Rust" , "?search=" ) ;
1621
1618
}
1622
- var main = document . getElementById ( "main" ) ;
1623
1619
if ( hasClass ( main , "content" ) ) {
1624
1620
removeClass ( main , "hidden" ) ;
1625
1621
}
@@ -1666,7 +1662,6 @@ if (!DOMTokenList.prototype.remove) {
1666
1662
// When browsing back from search results the main page
1667
1663
// visibility must be reset.
1668
1664
if ( ! params . search ) {
1669
- var main = document . getElementById ( "main" ) ;
1670
1665
if ( hasClass ( main , "content" ) ) {
1671
1666
removeClass ( main , "hidden" ) ;
1672
1667
}
@@ -1862,8 +1857,6 @@ if (!DOMTokenList.prototype.remove) {
1862
1857
window . register_implementors ( window . pending_implementors ) ;
1863
1858
}
1864
1859
1865
- console . log ( '4' , Date . now ( ) - start ) ;
1866
-
1867
1860
function labelForToggleButton ( sectionIsCollapsed ) {
1868
1861
if ( sectionIsCollapsed ) {
1869
1862
// button will expand the section
@@ -1889,31 +1882,35 @@ if (!DOMTokenList.prototype.remove) {
1889
1882
}
1890
1883
1891
1884
function toggleAllDocs ( pageId , fromAutoCollapse ) {
1892
- var toggle = document . getElementById ( "toggle-all-docs" ) ;
1893
- if ( ! toggle ) {
1885
+ var innerToggle = document . getElementById ( "toggle-all-docs" ) ;
1886
+ if ( ! innerToggle ) {
1894
1887
return ;
1895
1888
}
1896
- if ( hasClass ( toggle , "will-expand" ) ) {
1889
+ if ( hasClass ( innerToggle , "will-expand" ) ) {
1897
1890
updateLocalStorage ( "rustdoc-collapse" , "false" ) ;
1898
- removeClass ( toggle , "will-expand" ) ;
1899
- onEveryMatchingChild ( toggle , "inner" , function ( e ) {
1891
+ removeClass ( innerToggle , "will-expand" ) ;
1892
+ onEveryMatchingChild ( innerToggle , "inner" , function ( e ) {
1900
1893
e . innerHTML = labelForToggleButton ( false ) ;
1901
1894
} ) ;
1902
- toggle . title = "collapse all docs" ;
1895
+ innerToggle . title = "collapse all docs" ;
1903
1896
if ( fromAutoCollapse !== true ) {
1904
- onEach ( document . getElementsByClassName ( "collapse-toggle" ) , function ( e ) {
1897
+ onEach ( Array . prototype . slice . call (
1898
+ document . getElementsByClassName ( "collapse-toggle" ) ) ,
1899
+ function ( e ) {
1905
1900
collapseDocs ( e , "show" ) ;
1906
1901
} ) ;
1907
1902
}
1908
1903
} else {
1909
1904
updateLocalStorage ( "rustdoc-collapse" , "true" ) ;
1910
- addClass ( toggle , "will-expand" ) ;
1911
- onEveryMatchingChild ( toggle , "inner" , function ( e ) {
1905
+ addClass ( innerToggle , "will-expand" ) ;
1906
+ onEveryMatchingChild ( innerToggle , "inner" , function ( e ) {
1912
1907
e . innerHTML = labelForToggleButton ( true ) ;
1913
1908
} ) ;
1914
- toggle . title = "expand all docs" ;
1909
+ innerToggle . title = "expand all docs" ;
1915
1910
if ( fromAutoCollapse !== true ) {
1916
- onEach ( document . getElementsByClassName ( "collapse-toggle" ) , function ( e ) {
1911
+ onEach ( Array . prototype . slice . call (
1912
+ document . getElementsByClassName ( "collapse-toggle" ) ) ,
1913
+ function ( e ) {
1917
1914
collapseDocs ( e , "hide" , pageId ) ;
1918
1915
} ) ;
1919
1916
}
@@ -1987,12 +1984,12 @@ if (!DOMTokenList.prototype.remove) {
1987
1984
}
1988
1985
if ( action === "hide" ) {
1989
1986
addClass ( relatedDoc , "hidden-by-usual-hider" ) ;
1990
- onEach ( toggle . childNodes , adjustToggle ( true ) ) ;
1987
+ onEach ( Array . prototype . slice . call ( toggle . childNodes ) , adjustToggle ( true ) ) ;
1991
1988
addClass ( toggle . parentNode , "collapsed" ) ;
1992
1989
} else if ( action === "show" ) {
1993
1990
removeClass ( relatedDoc , "hidden-by-usual-hider" ) ;
1994
1991
removeClass ( toggle . parentNode , "collapsed" ) ;
1995
- onEach ( toggle . childNodes , adjustToggle ( false ) ) ;
1992
+ onEach ( Array . prototype . slice . call ( toggle . childNodes ) , adjustToggle ( false ) ) ;
1996
1993
}
1997
1994
}
1998
1995
} else {
@@ -2025,13 +2022,13 @@ if (!DOMTokenList.prototype.remove) {
2025
2022
if ( action === "show" ) {
2026
2023
removeClass ( relatedDoc , "fns-now-collapsed" ) ;
2027
2024
removeClass ( docblock , "hidden-by-usual-hider" ) ;
2028
- onEach ( toggle . childNodes , adjustToggle ( false ) ) ;
2029
- onEach ( relatedDoc . childNodes , implHider ( false ) ) ;
2025
+ onEach ( Array . prototype . slice . call ( toggle . childNodes ) , adjustToggle ( false ) ) ;
2026
+ onEach ( Array . prototype . slice . call ( relatedDoc . childNodes ) , implHider ( false ) ) ;
2030
2027
} else if ( action === "hide" ) {
2031
2028
addClass ( relatedDoc , "fns-now-collapsed" ) ;
2032
2029
addClass ( docblock , "hidden-by-usual-hider" ) ;
2033
- onEach ( toggle . childNodes , adjustToggle ( true ) ) ;
2034
- onEach ( relatedDoc . childNodes , implHider ( true ) ) ;
2030
+ onEach ( Array . prototype . slice . call ( toggle . childNodes ) , adjustToggle ( true ) ) ;
2031
+ onEach ( Array . prototype . slice . call ( relatedDoc . childNodes ) , implHider ( true ) ) ;
2035
2032
}
2036
2033
}
2037
2034
}
@@ -2055,7 +2052,9 @@ if (!DOMTokenList.prototype.remove) {
2055
2052
var impl_list = document . getElementById ( "implementations-list" ) ;
2056
2053
2057
2054
if ( impl_list !== null ) {
2058
- onEach ( impl_list . getElementsByClassName ( "collapse-toggle" ) , collapser ) ;
2055
+ onEach ( Array . prototype . slice . call (
2056
+ impl_list . getElementsByClassName ( "collapse-toggle" ) ) ,
2057
+ collapser ) ;
2059
2058
}
2060
2059
}
2061
2060
}
@@ -2069,30 +2068,30 @@ if (!DOMTokenList.prototype.remove) {
2069
2068
referenceNode . parentNode . insertBefore ( newNode , referenceNode . nextSibling ) ;
2070
2069
}
2071
2070
2072
- var toggle = document . createElement ( "a" ) ;
2073
- toggle . href = "javascript:void(0)" ;
2074
- toggle . className = "collapse-toggle" ;
2075
- toggle . innerHTML = "[<span class=\"inner\">" + labelForToggleButton ( false ) + "</span>]" ;
2071
+ function createSimpleToggle ( sectionIsCollapsed ) {
2072
+ var toggle = document . createElement ( "a" ) ;
2073
+ toggle . href = "javascript:void(0)" ;
2074
+ toggle . className = "collapse-toggle" ;
2075
+ toggle . innerHTML = "[<span class=\"inner\">" + labelForToggleButton ( sectionIsCollapsed ) +
2076
+ "</span>]" ;
2077
+ return toggle ;
2078
+ }
2079
+
2080
+ var toggle = createSimpleToggle ( false ) ;
2076
2081
2077
2082
var func = function ( e ) {
2078
2083
var next = e . nextElementSibling ;
2079
- if ( next && hasClass ( e , "impl" ) && hasClass ( next , "docblock" ) ) {
2080
- next = next . nextElementSibling ;
2081
- }
2082
2084
if ( ! next ) {
2083
2085
return ;
2084
2086
}
2085
- if ( ( hasClass ( e , "method" ) || hasClass ( e , "associatedconstant" ) ||
2086
- next . getElementsByClassName ( "method" ) . length > 0 ) &&
2087
- ( hasClass ( next , "docblock" ) ||
2088
- hasClass ( e , "impl" ) ||
2089
- ( hasClass ( next , "stability" ) &&
2090
- hasClass ( next . nextElementSibling , "docblock" ) ) ) ) {
2087
+ if ( hasClass ( next , "docblock" ) ||
2088
+ ( hasClass ( next , "stability" ) &&
2089
+ hasClass ( next . nextElementSibling , "docblock" ) ) ) {
2091
2090
insertAfter ( toggle . cloneNode ( true ) , e . childNodes [ e . childNodes . length - 1 ] ) ;
2092
2091
}
2093
2092
} ;
2094
2093
2095
- var func2 = function ( e ) {
2094
+ var funcImpl = function ( e ) {
2096
2095
var next = e . nextElementSibling ;
2097
2096
if ( next && hasClass ( next , "docblock" ) ) {
2098
2097
next = next . nextElementSibling ;
@@ -2105,13 +2104,9 @@ if (!DOMTokenList.prototype.remove) {
2105
2104
}
2106
2105
} ;
2107
2106
2108
- console . log ( '5' , Date . now ( ) - start ) ;
2109
- onEach ( document . getElementsByClassName ( "method" ) , func ) ;
2110
- console . log ( '6' , Date . now ( ) - start ) ;
2111
- onEach ( document . getElementsByClassName ( "associatedconstant" ) , func ) ;
2112
- console . log ( '7' , Date . now ( ) - start ) ;
2113
- onEach ( document . getElementsByClassName ( "impl" ) , func2 ) ;
2114
- console . log ( '8' , Date . now ( ) - start ) ;
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 ) ;
2115
2110
var impl_call = function ( ) { } ;
2116
2111
if ( getCurrentValue ( "rustdoc-method-docs" ) !== "false" ) {
2117
2112
impl_call = function ( e , newToggle , pageId ) {
@@ -2132,7 +2127,8 @@ if (!DOMTokenList.prototype.remove) {
2132
2127
function toggleClicked ( ) {
2133
2128
if ( hasClass ( this , "collapsed" ) ) {
2134
2129
removeClass ( this , "collapsed" ) ;
2135
- onEach ( this . parentNode . getElementsByClassName ( "hidden" ) , function ( x ) {
2130
+ onEach ( Array . prototype . slice . call ( this . parentNode . getElementsByClassName ( "hidden" ) ) ,
2131
+ function ( x ) {
2136
2132
if ( hasClass ( x , "content" ) === false ) {
2137
2133
removeClass ( x , "hidden" ) ;
2138
2134
addClass ( x , "x" ) ;
@@ -2142,7 +2138,8 @@ if (!DOMTokenList.prototype.remove) {
2142
2138
"</span>] Hide undocumented items" ;
2143
2139
} else {
2144
2140
addClass ( this , "collapsed" ) ;
2145
- onEach ( this . parentNode . getElementsByClassName ( "x" ) , function ( x ) {
2141
+ onEach ( Array . prototype . slice . call ( this . parentNode . getElementsByClassName ( "x" ) ) ,
2142
+ function ( x ) {
2146
2143
if ( hasClass ( x , "content" ) === false ) {
2147
2144
addClass ( x , "hidden" ) ;
2148
2145
removeClass ( x , "x" ) ;
@@ -2152,8 +2149,8 @@ if (!DOMTokenList.prototype.remove) {
2152
2149
"</span>] Show hidden undocumented items" ;
2153
2150
}
2154
2151
}
2155
- onEach ( document . getElementsByClassName ( "impl-items" ) , function ( e ) {
2156
- onEach ( e . getElementsByClassName ( "associatedconstant" ) , func ) ;
2152
+ onEach ( Array . prototype . slice . call ( document . getElementsByClassName ( "impl-items" ) ) , function ( e ) {
2153
+ onEach ( Array . prototype . slice . call ( e . getElementsByClassName ( "associatedconstant" ) ) , func ) ;
2157
2154
var hiddenElems = e . getElementsByClassName ( "hidden" ) ;
2158
2155
var needToggle = false ;
2159
2156
@@ -2166,13 +2163,12 @@ if (!DOMTokenList.prototype.remove) {
2166
2163
}
2167
2164
}
2168
2165
if ( needToggle === true ) {
2169
- var toggle = newToggle . cloneNode ( true ) ;
2170
- toggle . onclick = toggleClicked ;
2171
- e . insertBefore ( toggle , e . firstChild ) ;
2172
- impl_call ( e , toggle , pageId ) ;
2166
+ var inner_toggle = newToggle . cloneNode ( true ) ;
2167
+ inner_toggle . onclick = toggleClicked ;
2168
+ e . insertBefore ( inner_toggle , e . firstChild ) ;
2169
+ impl_call ( e , inner_toggle , pageId ) ;
2173
2170
}
2174
2171
} ) ;
2175
- console . log ( '9' , Date . now ( ) - start ) ;
2176
2172
2177
2173
function createToggle ( otherMessage , fontSize , extraClass , show ) {
2178
2174
var span = document . createElement ( "span" ) ;
@@ -2214,15 +2210,18 @@ if (!DOMTokenList.prototype.remove) {
2214
2210
if ( hasClass ( e , "autohide" ) ) {
2215
2211
var wrap = e . previousElementSibling ;
2216
2212
if ( wrap && hasClass ( wrap , "toggle-wrapper" ) ) {
2217
- var toggle = wrap . childNodes [ 0 ] ;
2213
+ var inner_toggle = wrap . childNodes [ 0 ] ;
2218
2214
var extra = e . childNodes [ 0 ] . tagName === "H3" ;
2219
2215
2220
2216
e . style . display = "none" ;
2221
2217
addClass ( wrap , "collapsed" ) ;
2222
- onEach ( toggle . getElementsByClassName ( "inner" ) , function ( e ) {
2218
+ onEach ( Array . prototype . slice . call ( inner_toggle . getElementsByClassName ( "inner" ) ) ,
2219
+ function ( e ) {
2223
2220
e . innerHTML = labelForToggleButton ( true ) ;
2224
2221
} ) ;
2225
- onEach ( toggle . getElementsByClassName ( "toggle-label" ) , function ( e ) {
2222
+ onEach ( Array . prototype . slice . call (
2223
+ inner_toggle . getElementsByClassName ( "toggle-label" ) ) ,
2224
+ function ( e ) {
2226
2225
e . style . display = "inline-block" ;
2227
2226
if ( extra === true ) {
2228
2227
i_e . innerHTML = " Show " + e . childNodes [ 0 ] . innerHTML ;
@@ -2269,40 +2268,28 @@ if (!DOMTokenList.prototype.remove) {
2269
2268
}
2270
2269
}
2271
2270
2272
- console . log ( '10' , Date . now ( ) - start ) ;
2273
- onEach ( document . getElementsByClassName ( "docblock" ) , buildToggleWrapper ) ;
2274
- console . log ( '11' , Date . now ( ) - start ) ;
2275
- onEach ( document . getElementsByClassName ( "sub-variant" ) , buildToggleWrapper ) ;
2276
- console . log ( '12' , Date . now ( ) - start ) ;
2277
-
2278
- function createToggleWrapper ( tog ) {
2279
- var span = document . createElement ( "span" ) ;
2280
- span . className = "toggle-label" ;
2281
- span . style . display = "none" ;
2282
- span . innerHTML = " Expand attributes" ;
2283
- tog . appendChild ( span ) ;
2284
-
2285
- var wrapper = document . createElement ( "div" ) ;
2286
- wrapper . className = "toggle-wrapper toggle-attributes" ;
2287
- wrapper . appendChild ( tog ) ;
2288
- return wrapper ;
2289
- }
2271
+ onEach ( Array . prototype . slice . call ( document . getElementsByClassName ( "docblock" ) ) ,
2272
+ buildToggleWrapper ) ;
2273
+ onEach ( Array . prototype . slice . call ( document . getElementsByClassName ( "sub-variant" ) ) ,
2274
+ buildToggleWrapper ) ;
2290
2275
2291
2276
// In the search display, allows to switch between tabs.
2292
2277
function printTab ( nb ) {
2293
2278
if ( nb === 0 || nb === 1 || nb === 2 ) {
2294
2279
currentTab = nb ;
2295
2280
}
2296
2281
var nb_copy = nb ;
2297
- onEach ( document . getElementById ( "titles" ) . childNodes , function ( elem ) {
2282
+ onEach ( Array . prototype . slice . call ( document . getElementById ( "titles" ) . childNodes ) ,
2283
+ function ( elem ) {
2298
2284
if ( nb_copy === 0 ) {
2299
2285
addClass ( elem , "selected" ) ;
2300
2286
} else {
2301
2287
removeClass ( elem , "selected" ) ;
2302
2288
}
2303
2289
nb_copy -= 1 ;
2304
2290
} ) ;
2305
- onEach ( document . getElementById ( "results" ) . childNodes , function ( elem ) {
2291
+ onEach ( Array . prototype . slice . call ( document . getElementById ( "results" ) . childNodes ) ,
2292
+ function ( elem ) {
2306
2293
if ( nb === 0 ) {
2307
2294
elem . style . display = "" ;
2308
2295
} else {
@@ -2312,18 +2299,31 @@ if (!DOMTokenList.prototype.remove) {
2312
2299
} ) ;
2313
2300
}
2314
2301
2302
+ function createToggleWrapper ( tog ) {
2303
+ var span = document . createElement ( "span" ) ;
2304
+ span . className = "toggle-label" ;
2305
+ span . style . display = "none" ;
2306
+ span . innerHTML = " Expand attributes" ;
2307
+ tog . appendChild ( span ) ;
2308
+
2309
+ var wrapper = document . createElement ( "div" ) ;
2310
+ wrapper . className = "toggle-wrapper toggle-attributes" ;
2311
+ wrapper . appendChild ( tog ) ;
2312
+ return wrapper ;
2313
+ }
2314
+
2315
2315
// To avoid checking on "rustdoc-item-attributes" value on every loop...
2316
2316
var itemAttributesFunc = function ( ) { } ;
2317
2317
if ( getCurrentValue ( "rustdoc-item-attributes" ) !== "false" ) {
2318
2318
itemAttributesFunc = function ( x ) {
2319
2319
collapseDocs ( x . previousSibling . childNodes [ 0 ] , "toggle" ) ;
2320
2320
} ;
2321
2321
}
2322
- onEach ( document . getElementById ( "main" ) . getElementsByClassName ( "attributes" ) , function ( i_e ) {
2323
- i_e . parentNode . insertBefore ( createToggleWrapper ( toggle . cloneNode ( true ) ) , i_e ) ;
2322
+ var attributesToggle = createToggleWrapper ( createSimpleToggle ( false ) ) ;
2323
+ onEach ( Array . prototype . slice . call ( main . getElementsByClassName ( "attributes" ) ) , function ( i_e ) {
2324
+ i_e . parentNode . insertBefore ( attributesToggle . cloneNode ( true ) , i_e ) ;
2324
2325
itemAttributesFunc ( i_e ) ;
2325
2326
} ) ;
2326
- console . log ( '12a' , Date . now ( ) - start ) ;
2327
2327
2328
2328
// To avoid checking on "rustdoc-line-numbers" value on every loop...
2329
2329
var lineNumbersFunc = function ( ) { } ;
@@ -2340,8 +2340,8 @@ if (!DOMTokenList.prototype.remove) {
2340
2340
x . parentNode . insertBefore ( node , x ) ;
2341
2341
} ;
2342
2342
}
2343
- console . log ( '13' , Date . now ( ) - start ) ;
2344
- onEach ( document . getElementsByClassName ( "rust-example-rendered" ) , function ( e ) {
2343
+ onEach ( Array . prototype . slice . call ( document . getElementsByClassName ( "rust-example-rendered" ) ) ,
2344
+ function ( e ) {
2345
2345
if ( hasClass ( e , "compile_fail" ) ) {
2346
2346
e . addEventListener ( "mouseover" , function ( event ) {
2347
2347
this . parentElement . previousElementSibling . childNodes [ 0 ] . style . color = "#f00" ;
@@ -2359,7 +2359,6 @@ if (!DOMTokenList.prototype.remove) {
2359
2359
}
2360
2360
lineNumbersFunc ( e ) ;
2361
2361
} ) ;
2362
- console . log ( '14' , Date . now ( ) - start ) ;
2363
2362
2364
2363
function showModal ( content ) {
2365
2364
var modal = document . createElement ( "div" ) ;
@@ -2380,16 +2379,16 @@ if (!DOMTokenList.prototype.remove) {
2380
2379
}
2381
2380
}
2382
2381
2383
- onEach ( document . getElementsByClassName ( "important-traits" ) , function ( e ) {
2382
+ onEach ( Array . prototype . slice . call ( document . getElementsByClassName ( "important-traits" ) ) ,
2383
+ function ( e ) {
2384
2384
e . onclick = function ( ) {
2385
2385
showModal ( e . lastElementChild . innerHTML ) ;
2386
2386
} ;
2387
2387
} ) ;
2388
- console . log ( '15' , Date . now ( ) - start ) ;
2389
2388
2390
2389
function putBackSearch ( search_input ) {
2391
2390
if ( search_input . value !== "" ) {
2392
- addClass ( document . getElementById ( " main" ) , "hidden" ) ;
2391
+ addClass ( main , "hidden" ) ;
2393
2392
removeClass ( document . getElementById ( "search" ) , "hidden" ) ;
2394
2393
if ( browserSupportsHistoryApi ( ) ) {
2395
2394
history . replaceState ( search_input . value ,
@@ -2407,7 +2406,7 @@ if (!DOMTokenList.prototype.remove) {
2407
2406
2408
2407
var params = getQueryStringParams ( ) ;
2409
2408
if ( params && params . search ) {
2410
- addClass ( document . getElementById ( " main" ) , "hidden" ) ;
2409
+ addClass ( main , "hidden" ) ;
2411
2410
var search = document . getElementById ( "search" ) ;
2412
2411
removeClass ( search , "hidden" ) ;
2413
2412
search . innerHTML = "<h3 style=\"text-align: center;\">Loading search results...</h3>" ;
@@ -2429,23 +2428,18 @@ if (!DOMTokenList.prototype.remove) {
2429
2428
hideSidebar ( ) ;
2430
2429
} ;
2431
2430
2432
- console . log ( '16' , Date . now ( ) - start ) ;
2433
2431
autoCollapse ( getPageId ( ) , getCurrentValue ( "rustdoc-collapse" ) === "true" ) ;
2434
- console . log ( '17' , Date . now ( ) - start ) ;
2435
2432
2436
2433
if ( window . location . hash && window . location . hash . length > 0 ) {
2437
2434
expandSection ( window . location . hash . replace ( / ^ # / , "" ) ) ;
2438
2435
}
2439
2436
2440
- var main = document . getElementById ( "main" ) ;
2441
2437
if ( main ) {
2442
- console . log ( '18' , Date . now ( ) - start ) ;
2443
- onEach ( main . childNodes , function ( e ) {
2438
+ onEach ( Array . prototype . slice . call ( main . childNodes ) , function ( e ) {
2444
2439
if ( e . tagName === "H2" || e . tagName === "H3" ) {
2445
2440
e . nextElementSibling . style . display = "block" ;
2446
2441
}
2447
2442
} ) ;
2448
- console . log ( '19' , Date . now ( ) - start ) ;
2449
2443
}
2450
2444
2451
2445
function addSearchOptions ( crates ) {
0 commit comments