diff options
| author | Michael Howell <michael@notriddle.com> | 2023-03-21 10:38:24 -0700 |
|---|---|---|
| committer | Michael Howell <michael@notriddle.com> | 2023-09-21 15:16:44 -0700 |
| commit | 20b93b951aaa75bd32ec1c1c63eac5dbccc35156 (patch) | |
| tree | 5c22422dc0f065d4216b2aef97fe2098c36dbba2 /src/librustdoc/html/static/js/main.js | |
| parent | 3583e86674749c279e7edd96641255bbf8595de1 (diff) | |
| download | rust-20b93b951aaa75bd32ec1c1c63eac5dbccc35156.tar.gz rust-20b93b951aaa75bd32ec1c1c63eac5dbccc35156.zip | |
rustdoc: wait for section to open before trying to highlight
This fixes a problem where hash rewriting doesn't work with `:target` CSS rules.
Diffstat (limited to 'src/librustdoc/html/static/js/main.js')
| -rw-r--r-- | src/librustdoc/html/static/js/main.js | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/librustdoc/html/static/js/main.js b/src/librustdoc/html/static/js/main.js index 970c2f2d45d..aa8fd7162ee 100644 --- a/src/librustdoc/html/static/js/main.js +++ b/src/librustdoc/html/static/js/main.js @@ -370,8 +370,12 @@ function preLoadCss(cssUrl) { item => { const numbered = /([^-]+)-([0-9]+)/.exec(item.id); if (item.id === assocId || (numbered && numbered[1] === assocId)) { - expandSection(item.id); - window.location = "#" + item.id; + openParentDetails(item); + item.scrollIntoView(); + // Let the section expand itself before trying to highlight + setTimeout(() => { + window.location.replace("#" + item.id); + }, 0); } } ); |
