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

Kevin Bullock kbullock+mercurial at ringworld.org
Wed Jul 5 15:27:12 EDT 2017


# HG changeset patch
# User Kevin Bullock <kbullock+mercurial at 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

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')));
     }


More information about the Mercurial-devel mailing list