|
223 | 223 | }
|
224 | 224 | }
|
225 | 225 | }
|
| 226 | + |
| 227 | + function expandSection() { |
| 228 | + var hash = getPageId(); |
| 229 | + if (hash === null) { |
| 230 | + return; |
| 231 | + } |
| 232 | + |
| 233 | + var elem = document.getElementById(hash); |
| 234 | + if (elem && isHidden(elem.offsetParent)) { |
| 235 | + var h3 = elem.parentNode.previousSibling; |
| 236 | + |
| 237 | + if (h3.tagName !== 'H3') { |
| 238 | + h3 = h3.previousSibling; // skip div.docblock |
| 239 | + } |
| 240 | + |
| 241 | + if (h3) { |
| 242 | + var collapses = h3.getElementsByClassName("collapse-toggle"); |
| 243 | + if (collapses.length > 0) { |
| 244 | + // The element is not visible, we need to make it appear! |
| 245 | + collapseDocs(collapses[0], "show"); |
| 246 | + } |
| 247 | + } |
| 248 | + } |
| 249 | + } |
| 250 | + |
| 251 | + function onHashChange(ev) { |
| 252 | + highlightSourceLines(ev); |
| 253 | + expandSection(); |
| 254 | + } |
| 255 | + |
226 | 256 | highlightSourceLines(null);
|
227 |
| - window.onhashchange = highlightSourceLines; |
| 257 | + window.onhashchange = onHashChange; |
228 | 258 |
|
229 | 259 | // Gets the human-readable string for the virtual-key code of the
|
230 | 260 | // given KeyboardEvent, ev.
|
|
2213 | 2243 | autoCollapse(getPageId(), getCurrentValue("rustdoc-collapse") === "true");
|
2214 | 2244 |
|
2215 | 2245 | if (window.location.hash && window.location.hash.length > 0) {
|
2216 |
| - var hash = getPageId(); |
2217 |
| - if (hash !== null) { |
2218 |
| - var elem = document.getElementById(hash); |
2219 |
| - if (elem && elem.offsetParent === null) { |
2220 |
| - if (elem.parentNode && elem.parentNode.previousSibling) { |
2221 |
| - var collapses = elem.parentNode |
2222 |
| - .previousSibling |
2223 |
| - .getElementsByClassName("collapse-toggle"); |
2224 |
| - if (collapses.length > 0) { |
2225 |
| - // The element is not visible, we need to make it appear! |
2226 |
| - collapseDocs(collapses[0], "show"); |
2227 |
| - } |
2228 |
| - } |
2229 |
| - } |
2230 |
| - } |
| 2246 | + expandSection(); |
2231 | 2247 | }
|
2232 | 2248 | }());
|
2233 | 2249 |
|
|
0 commit comments