Skip to content

Move some settings DOM generation out of JS #97139

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

Merged
merged 2 commits into from
May 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.9.2
0.9.3
16 changes: 13 additions & 3 deletions src/librustdoc/html/render/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -596,9 +596,19 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
|buf: &mut Buffer| {
write!(
buf,
"<link rel=\"stylesheet\" type=\"text/css\" \
href=\"{root_path}settings{suffix}.css\">\
<script defer src=\"{root_path}settings{suffix}.js\"></script>",
"<div class=\"main-heading\">\
<h1 class=\"fqn\">\
<span class=\"in-band\">Rustdoc settings</span>\
</h1>\
<span class=\"out-of-band\">\
<a id=\"back\" href=\"javascript:void(0)\" onclick=\"history.back();\">\
Back\
</a>\
</span>\
</div>\
<link rel=\"stylesheet\" type=\"text/css\" \
href=\"{root_path}settings{suffix}.css\">\
<script defer src=\"{root_path}settings{suffix}.js\"></script>",
root_path = page.static_root_path.unwrap_or(""),
suffix = page.resource_suffix,
)
Expand Down
18 changes: 2 additions & 16 deletions src/librustdoc/html/static/js/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,22 +206,8 @@
];

// Then we build the DOM.
let innerHTML = "";
let elementKind = "div";

if (isSettingsPage) {
elementKind = "section";
innerHTML = `<div class="main-heading">
<h1 class="fqn">
<span class="in-band">Rustdoc settings</span>
</h1>
<span class="out-of-band">
<a id="back" href="javascript:void(0)" onclick="history.back();">Back</a>
</span>
</div>`;
}
innerHTML += `<div class="settings">${buildSettingsPageSections(settings)}</div>`;

const elementKind = isSettingsPage ? "section" : "div";
const innerHTML = `<div class="settings">${buildSettingsPageSections(settings)}</div>`;
const el = document.createElement(elementKind);
el.id = "settings";
el.innerHTML = innerHTML;
Expand Down