Skip to content

Commit

Permalink
Rollup merge of #113094 - GuillaumeGomez:fix-invalid-div-tag-in-head,…
Browse files Browse the repository at this point in the history
… r=notriddle,fmease

Fix invalid HTML DIV tag used in HEAD

Fixes #113067.

The issue also nicely explains the whole problem.

r? ``@notriddle``
  • Loading branch information
Dylan-DPC committed Jun 28, 2023
2 parents e4e1a99 + acbfb8c commit a70842c
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 7 deletions.
1 change: 0 additions & 1 deletion src/librustdoc/html/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1525,7 +1525,6 @@ fn init_id_map() -> FxHashMap<Cow<'static, str>, usize> {
map.insert("toggle-all-docs".into(), 1);
map.insert("all-types".into(), 1);
map.insert("default-settings".into(), 1);
map.insert("rustdoc-vars".into(), 1);
map.insert("sidebar-vars".into(), 1);
map.insert("copy-path".into(), 1);
map.insert("TOC".into(), 1);
Expand Down
4 changes: 2 additions & 2 deletions src/librustdoc/html/static/js/source-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

// Local js definitions:
/* global addClass, getCurrentValue, onEachLazy, removeClass, browserSupportsHistoryApi */
/* global updateLocalStorage */
/* global updateLocalStorage, getVar */

"use strict";

(function() {

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

const NAME_OFFSET = 0;
const DIRS_OFFSET = 1;
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/static/js/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ function getCurrentValue(name) {
// Get a value from the rustdoc-vars div, which is used to convey data from
// Rust to the JS. If there is no such element, return null.
const getVar = (function getVar(name) {
const el = document.getElementById("rustdoc-vars");
const el = document.querySelector("head > meta[name='rustdoc-vars']");
return el ? el.attributes["data-" + name].value : null;
});

Expand Down
3 changes: 1 addition & 2 deletions src/librustdoc/html/templates/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
{% endfor %}
></script> {# #}
{% endif %}
<div id="rustdoc-vars" {#+ #}
<meta name="rustdoc-vars" {#+ #}
data-root-path="{{page.root_path|safe}}" {#+ #}
data-static-root-path="{{static_root_path|safe}}" {#+ #}
data-current-crate="{{layout.krate}}" {#+ #}
Expand All @@ -39,7 +39,6 @@
data-theme-dark-css="{{files.theme_dark_css}}" {#+ #}
data-theme-ayu-css="{{files.theme_ayu_css}}" {#+ #}
> {# #}
</div> {# #}
<script src="{{static_root_path|safe}}{{files.storage_js}}"></script> {# #}
{% if page.css_class.contains("crate") %}
<script defer src="{{page.root_path|safe}}crates{{page.resource_suffix}}.js"></script> {# #}
Expand Down
2 changes: 1 addition & 1 deletion tests/run-make/rustdoc-themes/foo.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @has test.css
// @has foo/struct.Foo.html
// @has - '//*[@id="rustdoc-vars"]/@data-themes' 'test'
// @has - '//*[@name="rustdoc-vars"]/@data-themes' 'test'
pub struct Foo;

0 comments on commit a70842c

Please sign in to comment.