Patchwork [3,of,3,website] downloads: skip trying to fill in button if it's not there

login
register
mail settings
Submitter Kevin Bullock
Date July 5, 2017, 7:27 p.m.
Message ID <ab7906d4526975cd8515.1499282832@ingalls.local>
Download mbox | patch
Permalink /patch/22015/
State Accepted
Headers show

Comments

Kevin Bullock - July 5, 2017, 7:27 p.m.
# HG changeset patch
# User Kevin Bullock <kbullock+mercurial@ringworld.org>
# Date 1494814512 18000
#      Sun May 14 21:15:12 2017 -0500
# Node ID ab7906d4526975cd8515d99f9f19ac31f53f004c
# Parent  5a7c3f2b2a5d6caacc0314e8433da1705360b9d3
downloads: skip trying to fill in button if it's not there
Sean Farley - July 6, 2017, 12:04 a.m.
Kevin Bullock <kbullock+mercurial@ringworld.org> writes:

> # HG changeset patch
> # User Kevin Bullock <kbullock+mercurial@ringworld.org>
> # Date 1494814512 18000
> #      Sun May 14 21:15:12 2017 -0500
> # Node ID ab7906d4526975cd8515d99f9f19ac31f53f004c
> # Parent  5a7c3f2b2a5d6caacc0314e8433da1705360b9d3
> downloads: skip trying to fill in button if it's not there

Awesome, queued!

Patch

diff --git a/static/js/download.js b/static/js/download.js
--- a/static/js/download.js
+++ b/static/js/download.js
@@ -135,10 +135,16 @@  var Downloader = {
 
 (function (document, window) {
     var load = function () {
+        var versElement = document.getElementById('download-version')
+          , descElement = document.getElementById('download-description');
+
+        if (!(versElement && descElement)) {
+            return;
+        }
+
         Downloader.init(sources);
         window.dl = Downloader.select();
-        var versElement = document.getElementById('download-version')
-          , descElement = document.getElementById('download-description');
+
         versElement.appendChild(document.createTextNode(dl.attr('version')));
         descElement.appendChild(document.createTextNode(dl.attr('desc')));
     }