Skip to content

Commit 88ac0e7

Browse files
authored
Rollup merge of #97139 - GuillaumeGomez:move-dom-settings-generation, 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`
2 parents 4fb2f33 + 30b536e commit 88ac0e7

File tree

3 files changed

+16
-20
lines changed

3 files changed

+16
-20
lines changed
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.9.2
1+
0.9.3

src/librustdoc/html/render/context.rs

+13-3
Original file line numberDiff line numberDiff line change
@@ -596,9 +596,19 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
596596
|buf: &mut Buffer| {
597597
write!(
598598
buf,
599-
"<link rel=\"stylesheet\" type=\"text/css\" \
600-
href=\"{root_path}settings{suffix}.css\">\
601-
<script defer src=\"{root_path}settings{suffix}.js\"></script>",
599+
"<div class=\"main-heading\">\
600+
<h1 class=\"fqn\">\
601+
<span class=\"in-band\">Rustdoc settings</span>\
602+
</h1>\
603+
<span class=\"out-of-band\">\
604+
<a id=\"back\" href=\"javascript:void(0)\" onclick=\"history.back();\">\
605+
Back\
606+
</a>\
607+
</span>\
608+
</div>\
609+
<link rel=\"stylesheet\" type=\"text/css\" \
610+
href=\"{root_path}settings{suffix}.css\">\
611+
<script defer src=\"{root_path}settings{suffix}.js\"></script>",
602612
root_path = page.static_root_path.unwrap_or(""),
603613
suffix = page.resource_suffix,
604614
)

src/librustdoc/html/static/js/settings.js

+2-16
Original file line numberDiff line numberDiff line change
@@ -206,22 +206,8 @@
206206
];
207207

208208
// Then we build the DOM.
209-
let innerHTML = "";
210-
let elementKind = "div";
211-
212-
if (isSettingsPage) {
213-
elementKind = "section";
214-
innerHTML = `<div class="main-heading">
215-
<h1 class="fqn">
216-
<span class="in-band">Rustdoc settings</span>
217-
</h1>
218-
<span class="out-of-band">
219-
<a id="back" href="javascript:void(0)" onclick="history.back();">Back</a>
220-
</span>
221-
</div>`;
222-
}
223-
innerHTML += `<div class="settings">${buildSettingsPageSections(settings)}</div>`;
224-
209+
const elementKind = isSettingsPage ? "section" : "div";
210+
const innerHTML = `<div class="settings">${buildSettingsPageSections(settings)}</div>`;
225211
const el = document.createElement(elementKind);
226212
el.id = "settings";
227213
el.innerHTML = innerHTML;

0 commit comments

Comments
 (0)