Skip to content

Commit c466791

Browse files
committed
Add event handler to stale version conditionally
1 parent d399df0 commit c466791

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

assets/js/sidebar/sidebar-version-select.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@ if (!isEmbedded) {
1616
if (versionNodes.length > 0 || !versionsContainer) {
1717
// Initially the container contains only text with the current version
1818
const currentVersion = versionsContainer.textContent.trim()
19+
1920
// Add the current version node to the list if not there.
2021
const withCurrentVersion = versionNodes.some((node) => node.version === currentVersion)
2122
? versionNodes
2223
: [{ version: currentVersion, url: '#' }, ...versionNodes]
24+
2325
// Add additional attributes to version nodes for rendering.
2426
const nodes = withCurrentVersion.map(node => ({
2527
...node,
@@ -36,7 +38,10 @@ if (!isEmbedded) {
3638
adjustWidth(select)
3739

3840
const versionsGoToLatest = qs('.sidebar-staleVersion a')
39-
versionsGoToLatest.addEventListener('click', handleGoToLatestClicked)
41+
42+
if(versionsGoToLatest) {
43+
versionsGoToLatest.addEventListener('click', handleGoToLatestClicked)
44+
}
4045
}
4146
}
4247

0 commit comments

Comments
 (0)