Skip to content

Commit a70842c

Browse files
authored
Rollup merge of #113094 - GuillaumeGomez:fix-invalid-div-tag-in-head, r=notriddle,fmease
Fix invalid HTML DIV tag used in HEAD Fixes #113067. The issue also nicely explains the whole problem. r? ``@notriddle``
2 parents e4e1a99 + acbfb8c commit a70842c

File tree

5 files changed

+5
-7
lines changed

5 files changed

+5
-7
lines changed

src/librustdoc/html/markdown.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1525,7 +1525,6 @@ fn init_id_map() -> FxHashMap<Cow<'static, str>, usize> {
15251525
map.insert("toggle-all-docs".into(), 1);
15261526
map.insert("all-types".into(), 1);
15271527
map.insert("default-settings".into(), 1);
1528-
map.insert("rustdoc-vars".into(), 1);
15291528
map.insert("sidebar-vars".into(), 1);
15301529
map.insert("copy-path".into(), 1);
15311530
map.insert("TOC".into(), 1);

src/librustdoc/html/static/js/source-script.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33

44
// Local js definitions:
55
/* global addClass, getCurrentValue, onEachLazy, removeClass, browserSupportsHistoryApi */
6-
/* global updateLocalStorage */
6+
/* global updateLocalStorage, getVar */
77

88
"use strict";
99

1010
(function() {
1111

12-
const rootPath = document.getElementById("rustdoc-vars").attributes["data-root-path"].value;
12+
const rootPath = getVar("root-path");
1313

1414
const NAME_OFFSET = 0;
1515
const DIRS_OFFSET = 1;

src/librustdoc/html/static/js/storage.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ function getCurrentValue(name) {
108108
// Get a value from the rustdoc-vars div, which is used to convey data from
109109
// Rust to the JS. If there is no such element, return null.
110110
const getVar = (function getVar(name) {
111-
const el = document.getElementById("rustdoc-vars");
111+
const el = document.querySelector("head > meta[name='rustdoc-vars']");
112112
return el ? el.attributes["data-" + name].value : null;
113113
});
114114

src/librustdoc/html/templates/page.html

+1-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
{% endfor %}
2525
></script> {# #}
2626
{% endif %}
27-
<div id="rustdoc-vars" {#+ #}
27+
<meta name="rustdoc-vars" {#+ #}
2828
data-root-path="{{page.root_path|safe}}" {#+ #}
2929
data-static-root-path="{{static_root_path|safe}}" {#+ #}
3030
data-current-crate="{{layout.krate}}" {#+ #}
@@ -39,7 +39,6 @@
3939
data-theme-dark-css="{{files.theme_dark_css}}" {#+ #}
4040
data-theme-ayu-css="{{files.theme_ayu_css}}" {#+ #}
4141
> {# #}
42-
</div> {# #}
4342
<script src="{{static_root_path|safe}}{{files.storage_js}}"></script> {# #}
4443
{% if page.css_class.contains("crate") %}
4544
<script defer src="{{page.root_path|safe}}crates{{page.resource_suffix}}.js"></script> {# #}

tests/run-make/rustdoc-themes/foo.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
// @has test.css
22
// @has foo/struct.Foo.html
3-
// @has - '//*[@id="rustdoc-vars"]/@data-themes' 'test'
3+
// @has - '//*[@name="rustdoc-vars"]/@data-themes' 'test'
44
pub struct Foo;

0 commit comments

Comments
 (0)