rustdoc: wait for section to open before trying to highlight

This fixes a problem where hash rewriting doesn't work with
`:target` CSS rules.
This commit is contained in:
Michael Howell 2023-03-21 10:38:24 -07:00
parent 3583e86674
commit 20b93b951a
2 changed files with 8 additions and 2 deletions

View File

@ -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);
}
}
);

View File

@ -20,6 +20,7 @@ wait-for: "#impl-ZyxwvutMethodDisambiguation"
assert-document-property: ({
"URL": "struct.ZyxwvutMethodDisambiguation.html#method.method_impl_disambiguation"
}, ENDS_WITH)
assert: "section:target"
goto: "file://" + |DOC_PATH| + "/test_docs/index.html"
@ -39,3 +40,4 @@ wait-for: "#impl-ZyxwvutMethodDisambiguation"
assert-document-property: ({
"URL": "struct.ZyxwvutMethodDisambiguation.html#method.method_impl_disambiguation-1"
}, ENDS_WITH)
assert: "section:target"