[rustdoc] Only generate search DOM elements if the search is actually needed - #160639
Conversation
|
Some changes occurred in HTML/CSS/JS. |
| @@ -16,6 +17,7 @@ define-function: ("collapsed-from-search", [], block { | |||
| // Then we collapse the section again... | |||
| set-property: ("#implementations-list .implementors-toggle", {"open": "false"}) | |||
| // Then we run the search. | |||
| call-function: ("open-search", {}) | |||
There was a problem hiding this comment.
Ah that was my original "quest": looking at fixing the new flakyness which happened in #159593 (comment). ^^'
This comment has been minimized.
This comment has been minimized.
24284c5 to
977669b
Compare
|
Added the missing Typescript type definition update and CI is now happy. |
|
Added comments as suggested for clarification. |
| // If you're browsing the nightly docs, the page might need to be refreshed for | ||
| // the search to work because the hash of the JS scripts might have changed. |
There was a problem hiding this comment.
nit: technically this doesn't just apply to nightly, it's just way more common there
| if (!window.StringdexOnload) { | ||
| window.StringdexOnload = []; | ||
| } | ||
| window.StringdexOnload.push(() => { | ||
| loadScript( | ||
| getVar("static-root-path") + getVar("search-js"), | ||
| sendSearchForm, | ||
| ); | ||
| }); |
There was a problem hiding this comment.
the structure of this doesn't make a ton of sense to me in combination, shouldn't we just be initializing it to an array with a single element? otherwise we could hypothetically end up with an array of duplicate initializers?
There was a problem hiding this comment.
Just moved existing code, didn't modify anything. I think it's because you can have multiple search indexes loaded in parallel.
| // We load the search input. | ||
| window.searchState.inputElement(); |
There was a problem hiding this comment.
best i can tell, inputElement() doesn't directly load the search, it sets up a focus handler that loads the search.. why not just load the search and get something more readable and less indirect?
There was a problem hiding this comment.
I'll improve the comment as it's quite unclear.
3367289 to
730e9a6
Compare
|
Improved the problematic comment. As I mentioned, the rest is just code I moved around. |
|
@bors r+ |
…narycat [rustdoc] Only generate search DOM elements if the search is actually needed I realized that we were generating the search DOM elements (everything contained into `#search`) all the times, even when there is no search query parameters in the URL. That seems unnecessary so I reworked the JS a bit to remove that. r? @lolbinarycat
…narycat [rustdoc] Only generate search DOM elements if the search is actually needed I realized that we were generating the search DOM elements (everything contained into `#search`) all the times, even when there is no search query parameters in the URL. That seems unnecessary so I reworked the JS a bit to remove that. r? @lolbinarycat
…uwer Rollup of 26 pull requests Successful merges: - #161384 (Bust sccache's cache) - #161325 (Bump bootstrap to 1.99.0-beta.1) - #161344 (Update the `rustc-perf` submodule) - #161366 (Subtree sync for rustc_codegen_cranelift) - #159071 ([PAC] Encoder and hash (1/8)) - #160639 ([rustdoc] Only generate search DOM elements if the search is actually needed) - #161068 (Ensure TLS accesses don't call the global allocator through panic (part 3) ) - #161332 (Some `GlobalCtxt`/`Session` cleanups) - #150931 (rustdoc: Always document `#[repr(transparent)]` if `#[rustc_pub_transparent]` is applied) - #158999 (doc: list all remove_dir_all fallback targets) - #160582 (Add `remove hidden_glob_reexports item breaks downstream` test) - #160876 (remove unwrap from write_mir_fn_graphviz) - #160927 (Enhance EII UI tests) - #161070 (fix arm homogeneous aggregate ABI) - #161190 (fix crash in async-drop and async-gen) - #161236 (Download auto jobs in citool in parallel) - #161254 (Reserve capacity for 3% anon nodes) - #161283 (Tighten the language used for documenting `TargetOptions::llvm_abiname`) - #161291 (Rename `ProjectionPredicate` and `TraitPredicate`) - #161293 (add relnotes 1.98.0) - #161299 (Remove a bunch of unnecessary explicit lifetimes) - #161307 (make ARM maintainers pingable) - #161308 (Add regression test for rustc diagnostic to recognize variables in match guards) - #161346 (Don't rely on std traits not being const in tests) - #161360 (vec: fixup the name that i forgot) - #161367 (Reflect current PR title names for subtree syncs in triagebot no-merges)
Rollup merge of #160639 - GuillaumeGomez:search-dom, r=lolbinarycat [rustdoc] Only generate search DOM elements if the search is actually needed I realized that we were generating the search DOM elements (everything contained into `#search`) all the times, even when there is no search query parameters in the URL. That seems unnecessary so I reworked the JS a bit to remove that. r? @lolbinarycat
I realized that we were generating the search DOM elements (everything contained into
#search) all the times, even when there is no search query parameters in the URL. That seems unnecessary so I reworked the JS a bit to remove that.r? @lolbinarycat