@@ -1790,14 +1790,12 @@ href="https://doc.rust-lang.org/${channel}/rustdoc/read-documentation/search.htm
1790
1790
*/
1791
1791
let pendingSidebarResizingFrame = false ;
1792
1792
1793
- /** @type {HTMLElement } */
1794
- // @ts -expect-error
1793
+ /** @type {HTMLElement|null } */
1795
1794
const resizer = document . querySelector ( ".sidebar-resizer" ) ;
1796
- /** @type {HTMLElement } */
1797
- // @ts -expect-error
1795
+ /** @type {HTMLElement|null } */
1798
1796
const sidebar = document . querySelector ( ".sidebar" ) ;
1799
1797
// If this page has no sidebar at all, bail out.
1800
- if ( ! ( resizer instanceof HTMLElement ) || ! ( sidebar instanceof HTMLElement ) ) {
1798
+ if ( ! resizer || ! sidebar ) {
1801
1799
return ;
1802
1800
}
1803
1801
@@ -1813,7 +1811,7 @@ href="https://doc.rust-lang.org/${channel}/rustdoc/read-documentation/search.htm
1813
1811
// from settings.js, which uses a separate function. It's done here because
1814
1812
// the minimum sidebar size is rather uncomfortable, and it must pass
1815
1813
// through that size when using the shrink-to-nothing gesture.
1816
- function hideSidebar ( ) {
1814
+ const hideSidebar = function hideSidebar ( ) {
1817
1815
if ( isSrcPage ) {
1818
1816
window . rustdocCloseSourceSidebar ( ) ;
1819
1817
updateLocalStorage ( "src-sidebar-width" , null ) ;
@@ -1838,30 +1836,30 @@ href="https://doc.rust-lang.org/${channel}/rustdoc/read-documentation/search.htm
1838
1836
sidebar . style . removeProperty ( "--desktop-sidebar-width" ) ;
1839
1837
resizer . style . removeProperty ( "--desktop-sidebar-width" ) ;
1840
1838
}
1841
- }
1839
+ } ;
1842
1840
1843
1841
// Call this function to show the sidebar from the resize handle.
1844
1842
// On docs pages, this can only happen if the user has grabbed the resize
1845
1843
// handle, shrunk the sidebar down to nothing, and then pulls back into
1846
1844
// the visible range without releasing it. You can, however, grab the
1847
1845
// resize handle on a source page with the sidebar closed, because it
1848
1846
// remains visible all the time on there.
1849
- function showSidebar ( ) {
1847
+ const showSidebar = function showSidebar ( ) {
1850
1848
if ( isSrcPage ) {
1851
1849
window . rustdocShowSourceSidebar ( ) ;
1852
1850
} else {
1853
1851
removeClass ( document . documentElement , "hide-sidebar" ) ;
1854
1852
updateLocalStorage ( "hide-sidebar" , "false" ) ;
1855
1853
}
1856
- }
1854
+ } ;
1857
1855
1858
1856
/**
1859
1857
* Call this to set the correct CSS variable and setting.
1860
1858
* This function doesn't enforce size constraints. Do that before calling it!
1861
1859
*
1862
1860
* @param {number } size - CSS px width of the sidebar.
1863
1861
*/
1864
- function changeSidebarSize ( size ) {
1862
+ const changeSidebarSize = function changeSidebarSize ( size ) {
1865
1863
if ( isSrcPage ) {
1866
1864
updateLocalStorage ( "src-sidebar-width" , size . toString ( ) ) ;
1867
1865
// [RUSTDOCIMPL] CSS variable fast path
@@ -1877,7 +1875,7 @@ href="https://doc.rust-lang.org/${channel}/rustdoc/read-documentation/search.htm
1877
1875
sidebar . style . setProperty ( "--desktop-sidebar-width" , size + "px" ) ;
1878
1876
resizer . style . setProperty ( "--desktop-sidebar-width" , size + "px" ) ;
1879
1877
}
1880
- }
1878
+ } ;
1881
1879
1882
1880
// Check if the sidebar is hidden. Since src pages and doc pages have
1883
1881
// different settings, this function has to check that.
@@ -1942,7 +1940,7 @@ href="https://doc.rust-lang.org/${channel}/rustdoc/read-documentation/search.htm
1942
1940
/**
1943
1941
* @param {PointerEvent= } e
1944
1942
*/
1945
- function stopResize ( e ) {
1943
+ const stopResize = function stopResize ( e ) {
1946
1944
if ( currentPointerId === null ) {
1947
1945
return ;
1948
1946
}
@@ -1959,12 +1957,12 @@ href="https://doc.rust-lang.org/${channel}/rustdoc/read-documentation/search.htm
1959
1957
resizer . releasePointerCapture ( currentPointerId ) ;
1960
1958
currentPointerId = null ;
1961
1959
}
1962
- }
1960
+ } ;
1963
1961
1964
1962
/**
1965
1963
* @param {PointerEvent } e
1966
1964
*/
1967
- function initResize ( e ) {
1965
+ const initResize = function initResize ( e ) {
1968
1966
if ( currentPointerId !== null || e . altKey || e . ctrlKey || e . metaKey || e . button !== 0 ) {
1969
1967
return ;
1970
1968
}
@@ -1988,7 +1986,7 @@ href="https://doc.rust-lang.org/${channel}/rustdoc/read-documentation/search.htm
1988
1986
const pos = e . clientX - sidebar . offsetLeft - 3 ;
1989
1987
document . documentElement . style . setProperty ( "--resizing-sidebar-width" , pos + "px" ) ;
1990
1988
desiredSidebarSize = null ;
1991
- }
1989
+ } ;
1992
1990
resizer . addEventListener ( "pointerdown" , initResize , false ) ;
1993
1991
} ( ) ) ;
1994
1992
0 commit comments