[BUGFIX] Guard version switcher against a missing selector - #1361
Open
CybotTM wants to merge 1 commit into
Open
Conversation
CybotTM
marked this pull request as draft
July 31, 2026 12:38
CybotTM
marked this pull request as ready for review
July 31, 2026 17:46
versions.js assumed every page has #versionSelect and #languageSelect and called versionSelect.getAttribute() unconditionally. On pages without the switcher (e.g. the search results page at /search) versionSelect is null, so the script threw "Cannot read properties of null (reading 'getAttribute')" (and, further down, "reading 'addEventListener'"), aborting the remaining page scripts. Bail out early when the switcher is absent. Adds a regression test and rebuilds theme.min.js. Signed-off-by: Sebastian Mendel <github@sebastianmendel.de>
CybotTM
force-pushed
the
bugfix/version-switcher-null-on-search
branch
from
July 31, 2026 17:52
fb4e5a1 to
c17fda4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On the search results page (
/search) the version-switcher script throws uncaught errors, which abort the remaining page scripts:versions.jslooks up#versionSelect/#languageSelectand then callsversionSelect.getAttribute(...)unconditionally. Those elements only exist on manual pages — on the search results pageversionSelectisnull.See it live (current production, not yet fixed — open the browser console): https://docs.typo3.org/search/search?q=openai&filters%5Bpackage%5D=netresearch/nr-llm
Fix
Bail out early in
versions.jswhen the switcher is absent. Adds a regression test and rebuildstheme.min.js(grunt js).Verification — console before / after
Headless Chromium against the live page above, routing
theme.min.jsto the build from this PR:Both
versions.jsnull errors are gone; only the unrelateduniverseerror remains.npm test-> 28 passed.Note
The
Unexpected token 'export'comes from thetypo3infrastructure/universebundle (outside this repository) — a separate issue for the infrastructure maintainers, not addressed here.