Skip to content

Commit

Permalink
Fixed side effect of scope on outdated banner (#7959)
Browse files Browse the repository at this point in the history
  • Loading branch information
squidfunk authored Feb 3, 2025
1 parent 26a32ea commit cf46186
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 10 deletions.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion material/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@
</script>
{% endblock %}
{% block scripts %}
<script src="{{ 'assets/javascripts/bundle.5090c770.min.js' | url }}"></script>
<script src="{{ 'assets/javascripts/bundle.f13b1293.min.js' | url }}"></script>
{% for script in config.extra_javascript %}
{{ script | script_tag }}
{% endfor %}
Expand Down
2 changes: 1 addition & 1 deletion material/templates/partials/javascripts/outdated.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{#-
This file was automatically generated - do not edit
-#}
<script>var el=document.querySelector("[data-md-component=outdated]"),outdated=__md_get("__outdated",sessionStorage);!0===outdated&&el&&(el.hidden=!1)</script>
<script>var el=document.querySelector("[data-md-component=outdated]"),base=new URL("{{ base_url }}"),outdated=__md_get("__outdated",sessionStorage,base);!0===outdated&&el&&(el.hidden=!1)</script>
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,11 @@ export function setupVersionSelector(
document$.pipe(switchMap(() => current$))
.subscribe(current => {

// Always scope outdate version banner to the base URL of the site
const base = new URL(config.base)

/* Check if version state was already determined */
let outdated = __md_get("__outdated", sessionStorage)
let outdated = __md_get("__outdated", sessionStorage, base)
if (outdated === null) {
outdated = true

Expand All @@ -177,7 +180,7 @@ export function setupVersionSelector(
}

/* Persist version state in session storage */
__md_set("__outdated", outdated, sessionStorage)
__md_set("__outdated", outdated, sessionStorage, base)
}

/* Unhide outdated version banner */
Expand Down
3 changes: 2 additions & 1 deletion src/templates/partials/javascripts/outdated.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
<!-- Version warning -->
<script>
var el = document.querySelector("[data-md-component=outdated]")
var outdated = __md_get("__outdated", sessionStorage)
var base = new URL("{{ base_url }}");
var outdated = __md_get("__outdated", sessionStorage, base)
if (outdated === true && el)
el.hidden = false
</script>

0 comments on commit cf46186

Please sign in to comment.