Skip to content

Commit c215a78

Browse files
authored
Restore _create_placeholders_if_missing() (#296)
1 parent 9a365d6 commit c215a78

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

Diff for: templates/switchers.js

+26
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,30 @@ const _CURRENT_PREFIX = (() => {
2828
const _ALL_VERSIONS = new Map($VERSIONS);
2929
const _ALL_LANGUAGES = new Map($LANGUAGES);
3030

31+
/**
32+
* Required for Python 3.7 and earlier.
33+
* @returns {void}
34+
* @private
35+
*/
36+
const _create_placeholders_if_missing = () => {
37+
if (document.querySelectorAll(".version_switcher_placeholder").length) return;
38+
39+
const items = document.querySelectorAll("body>div.related>ul>li:not(.right)");
40+
for (const item of items) {
41+
if (item.innerText.toLowerCase().includes("documentation")) {
42+
const container = document.createElement("li");
43+
container.className = "switchers";
44+
for (const placeholder_name of ["language", "version"]) {
45+
const placeholder = document.createElement("div");
46+
placeholder.className = `${placeholder_name}_switcher_placeholder`;
47+
container.appendChild(placeholder);
48+
}
49+
item.parentElement.insertBefore(container, item);
50+
return;
51+
}
52+
}
53+
};
54+
3155
/**
3256
* @param {Map<string, string>} versions
3357
* @returns {HTMLSelectElement}
@@ -175,6 +199,8 @@ const _initialise_switchers = () => {
175199
const versions = _ALL_VERSIONS;
176200
const languages = _ALL_LANGUAGES;
177201

202+
_create_placeholders_if_missing();
203+
178204
document
179205
.querySelectorAll(".version_switcher_placeholder")
180206
.forEach((placeholder) => {

0 commit comments

Comments
 (0)