Skip to content

Commit

Permalink
Rollup merge of rust-lang#97139 - GuillaumeGomez:move-dom-settings-ge…
Browse files Browse the repository at this point in the history
…neration, r=notriddle

Move some settings DOM generation out of JS

The first commit reduce the JS size a bit by moving some DOM content generation into the HTML file directly.

The second commit is an update of the `browser-ui-test` version which improves `wait-for-*` command (if the element doesn't exist, it'll wait for it instead of failing).

r? `@notriddle`
  • Loading branch information
JohnTitor authored May 18, 2022
2 parents 4fb2f33 + 30b536e commit 88ac0e7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 20 deletions.
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

0 comments on commit 88ac0e7

Please sign in to comment.