From b8e4c54ffb38885a9abd11ce2903af85cb62861f Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 27 Jun 2023 14:33:04 +0200 Subject: [PATCH 1/2] Fix invalid HTML DIV tag used in HEAD --- src/librustdoc/html/templates/page.html | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/librustdoc/html/templates/page.html b/src/librustdoc/html/templates/page.html index 759c4fd601226..24f045f5ce3bf 100644 --- a/src/librustdoc/html/templates/page.html +++ b/src/librustdoc/html/templates/page.html @@ -24,7 +24,7 @@ {% endfor %} > {# #} {% endif %} -
{# #} -
{# #} {# #} {% if page.css_class.contains("crate") %} {# #} From acbfb8c3bdbcb29b23b11221ae2ec1386b061aa7 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 27 Jun 2023 17:18:50 +0200 Subject: [PATCH 2/2] Replace `id` attribute with `name` for `` tag --- src/librustdoc/html/markdown.rs | 1 - src/librustdoc/html/static/js/source-script.js | 4 ++-- src/librustdoc/html/static/js/storage.js | 2 +- src/librustdoc/html/templates/page.html | 2 +- tests/run-make/rustdoc-themes/foo.rs | 2 +- 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index 1c27320024a9f..fd00277e2137d 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -1525,7 +1525,6 @@ fn init_id_map() -> FxHashMap, 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); diff --git a/src/librustdoc/html/static/js/source-script.js b/src/librustdoc/html/static/js/source-script.js index d999f3b36fd82..6eb991360404a 100644 --- a/src/librustdoc/html/static/js/source-script.js +++ b/src/librustdoc/html/static/js/source-script.js @@ -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; diff --git a/src/librustdoc/html/static/js/storage.js b/src/librustdoc/html/static/js/storage.js index 93979a944183b..71961f6f2a9c3 100644 --- a/src/librustdoc/html/static/js/storage.js +++ b/src/librustdoc/html/static/js/storage.js @@ -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; }); diff --git a/src/librustdoc/html/templates/page.html b/src/librustdoc/html/templates/page.html index 24f045f5ce3bf..d4ec9c34b6ffa 100644 --- a/src/librustdoc/html/templates/page.html +++ b/src/librustdoc/html/templates/page.html @@ -24,7 +24,7 @@ {% endfor %} > {# #} {% endif %} -