-
-
Notifications
You must be signed in to change notification settings - Fork 14.5k
rustdoc: more js cleanup #151386
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
rustdoc: more js cleanup #151386
Changes from all commits
ca5a254
b7ba80d
760d886
38d7b53
3b4de4b
519c0d9
bd1c36a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -231,7 +231,6 @@ function preLoadCss(cssUrl) { | |
| // When loading settings.html as a standalone page, the equivalent HTML is | ||
| // generated in context.rs. | ||
| setTimeout(() => { | ||
| // @ts-expect-error | ||
| const themes = getVar("themes").split(","); | ||
| for (const theme of themes) { | ||
| // if there are no themes, do nothing | ||
|
|
@@ -415,12 +414,10 @@ function preLoadCss(cssUrl) { | |
| } | ||
| window.StringdexOnload.push(() => { | ||
| loadScript( | ||
| // @ts-expect-error | ||
| getVar("static-root-path") + getVar("search-js"), | ||
| sendSearchForm, | ||
| ); | ||
| }); | ||
| // @ts-expect-error | ||
| loadScript(getVar("static-root-path") + getVar("stringdex-js"), sendSearchForm); | ||
| loadScript(resourcePath("search.index/root", ".js"), sendSearchForm); | ||
| } | ||
|
|
@@ -622,8 +619,7 @@ function preLoadCss(cssUrl) { | |
| */ | ||
| function openParentDetails(elem) { | ||
| while (elem) { | ||
| if (elem.tagName === "DETAILS") { | ||
| // @ts-expect-error | ||
| if (elem instanceof HTMLDetailsElement) { | ||
| elem.open = true; | ||
| } | ||
| elem = elem.parentElement; | ||
|
|
@@ -659,10 +655,8 @@ function preLoadCss(cssUrl) { | |
| } | ||
|
|
||
| if (document.activeElement && | ||
| document.activeElement.tagName === "INPUT" && | ||
| // @ts-expect-error | ||
| document.activeElement instanceof HTMLInputElement && | ||
| document.activeElement.type !== "checkbox" && | ||
| // @ts-expect-error | ||
| document.activeElement.type !== "radio") { | ||
| switch (getVirtualKey(ev)) { | ||
| case "Escape": | ||
|
|
@@ -969,19 +963,19 @@ function preLoadCss(cssUrl) { | |
| const selfPath = script ? script.getAttribute("data-self-path") : null; | ||
|
|
||
| // These sidebar blocks need filled in, too. | ||
| const mainContent = document.querySelector("#main-content"); | ||
| const sidebarSection = document.querySelector(".sidebar section"); | ||
| const mainContent = nonnull(document.querySelector("#main-content")); | ||
| const sidebarSection = nonnull(document.querySelector(".sidebar section")); | ||
| let methods = document.querySelector(".sidebar .block.method"); | ||
| let associatedTypes = document.querySelector(".sidebar .block.associatedtype"); | ||
| let associatedConstants = document.querySelector(".sidebar .block.associatedconstant"); | ||
| let sidebarTraitList = document.querySelector(".sidebar .block.trait-implementation"); | ||
|
|
||
| // @ts-expect-error | ||
| for (const impList of imp[window.currentCrate]) { | ||
| for (const impList of imp[nonnull(window.currentCrate)]) { | ||
| const types = impList.slice(2); | ||
| const text = impList[0]; | ||
| const isTrait = impList[1] !== 0; | ||
| const traitName = impList[1]; | ||
| const isTrait = typeof traitName === "string"; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's not the same check at all. Is there a reason why we go from integer comparison to checking it's a string? (lack of context on my side here)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see. JS is weird and we really abuse it sometimes. XD |
||
| // @ts-expect-error | ||
| if (types.indexOf(selfPath) === -1) { | ||
| continue; | ||
| } | ||
|
|
@@ -1005,28 +999,19 @@ function preLoadCss(cssUrl) { | |
| h.appendChild(link); | ||
| trait_implementations = outputList; | ||
| trait_implementations_header = outputListHeader; | ||
| // @ts-expect-error | ||
| sidebarSection.appendChild(h); | ||
| sidebarTraitList = document.createElement("ul"); | ||
| sidebarTraitList.className = "block trait-implementation"; | ||
| // @ts-expect-error | ||
| sidebarSection.appendChild(sidebarTraitList); | ||
| // @ts-expect-error | ||
| mainContent.appendChild(outputListHeader); | ||
| // @ts-expect-error | ||
| mainContent.appendChild(outputList); | ||
| } else { | ||
| implementations = outputList; | ||
| if (trait_implementations) { | ||
| // @ts-expect-error | ||
| mainContent.insertBefore(outputListHeader, trait_implementations_header); | ||
| // @ts-expect-error | ||
| mainContent.insertBefore(outputList, trait_implementations_header); | ||
| } else { | ||
| const mainContent = document.querySelector("#main-content"); | ||
| // @ts-expect-error | ||
| mainContent.appendChild(outputListHeader); | ||
| // @ts-expect-error | ||
| mainContent.appendChild(outputList); | ||
| } | ||
| } | ||
|
|
@@ -1071,8 +1056,7 @@ function preLoadCss(cssUrl) { | |
| if (isTrait) { | ||
| const li = document.createElement("li"); | ||
| const a = document.createElement("a"); | ||
| // @ts-expect-error | ||
| a.href = `#${template.content.querySelector(".impl").id}`; | ||
| a.href = `#${nonnull(template.content.querySelector(".impl")).id}`; | ||
| a.textContent = traitName; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why does this one has
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It shouldn't, I think the intermediate commit got messed up by some rebasing.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, wait, I misread the diff, this is also
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add this as comment so future us will not have to search again for this explanation please?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah will do. i originally didn't because i hoped i could find a way to get rid of it easily. |
||
| li.appendChild(a); | ||
| // @ts-expect-error | ||
|
|
@@ -1099,14 +1083,10 @@ function preLoadCss(cssUrl) { | |
| const insertionReference = methods || sidebarTraitList; | ||
| if (insertionReference) { | ||
| const insertionReferenceH = insertionReference.previousElementSibling; | ||
| // @ts-expect-error | ||
| sidebarSection.insertBefore(blockHeader, insertionReferenceH); | ||
| // @ts-expect-error | ||
| sidebarSection.insertBefore(block, insertionReferenceH); | ||
| } else { | ||
| // @ts-expect-error | ||
| sidebarSection.appendChild(blockHeader); | ||
| // @ts-expect-error | ||
| sidebarSection.appendChild(block); | ||
| } | ||
| if (hasClass(item, "associatedtype")) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although it's more correct, I find it so much less readable. ^^' (nothing to change here, just me sad that better code doesn't always look better)