Skip to content

Commit 6b2715a

Browse files
XhmikosRTrott
authored andcommitted
Revert "main.js: return early if buttons aren't present (#3853)"
This reverts commit dec85fd.
1 parent 181bcd1 commit 6b2715a

File tree

1 file changed

+19
-21
lines changed

1 file changed

+19
-21
lines changed

static/js/main.js

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -182,20 +182,15 @@
182182
;(function () {
183183
'use strict'
184184

185-
var buttons = document.querySelectorAll('.home-downloadbutton')
186-
var downloadHead = document.querySelector('#home-downloadhead')
187-
188-
if (!downloadHead || !buttons) {
189-
return
190-
}
191-
192185
var osMatch = navigator.platform.match(/(Win|Mac|Linux)/)
193186
var os = (osMatch && osMatch[1]) || ''
194187
var arch = navigator.userAgent.match(/x86_64|Win64|WOW64/) ||
195188
navigator.cpuClass === 'x64'
196189
? 'x64'
197190
: 'x86'
198-
var dlLocal = downloadHead.getAttribute('data-dl-local')
191+
var buttons = document.querySelectorAll('.home-downloadbutton')
192+
var downloadHead = document.querySelector('#home-downloadhead')
193+
var dlLocal
199194

200195
function versionIntoHref (nodeList, filename) {
201196
var linkEls = Array.prototype.slice.call(nodeList)
@@ -215,19 +210,22 @@
215210
}
216211
}
217212

218-
switch (os) {
219-
case 'Mac':
220-
versionIntoHref(buttons, 'node-%version%.pkg')
221-
downloadHead.textContent = dlLocal + ' macOS (x64)'
222-
break
223-
case 'Win':
224-
versionIntoHref(buttons, 'node-%version%-' + arch + '.msi')
225-
downloadHead.textContent = dlLocal + ' Windows (' + arch + ')'
226-
break
227-
case 'Linux':
228-
versionIntoHref(buttons, 'node-%version%-linux-x64.tar.xz')
229-
downloadHead.textContent = dlLocal + ' Linux (x64)'
230-
break
213+
if (downloadHead && buttons) {
214+
dlLocal = downloadHead.getAttribute('data-dl-local')
215+
switch (os) {
216+
case 'Mac':
217+
versionIntoHref(buttons, 'node-%version%.pkg')
218+
downloadHead.textContent = dlLocal + ' macOS (x64)'
219+
break
220+
case 'Win':
221+
versionIntoHref(buttons, 'node-%version%-' + arch + '.msi')
222+
downloadHead.textContent = dlLocal + ' Windows (' + arch + ')'
223+
break
224+
case 'Linux':
225+
versionIntoHref(buttons, 'node-%version%-linux-x64.tar.xz')
226+
downloadHead.textContent = dlLocal + ' Linux (x64)'
227+
break
228+
}
231229
}
232230

233231
// Windows button on download page

0 commit comments

Comments
 (0)