Patchwork [6,of,7] hgweb: look up "URLSearchParams" in "window" to work around jshint issues

login
register
mail settings
Submitter Anton Shestakov
Date Nov. 27, 2017, 9:28 a.m.
Message ID <b95d29f0e64c433c40ec.1511774893@neuro>
Download mbox | patch
Permalink /patch/25768/
State Accepted
Headers show

Comments

Anton Shestakov - Nov. 27, 2017, 9:28 a.m.
# HG changeset patch
# User Anton Shestakov <av6@dwimlabs.net>
# Date 1511359897 -28800
#      Wed Nov 22 22:11:37 2017 +0800
# Node ID b95d29f0e64c433c40ec23ad415f848d3c77429b
# Parent  32c7b8d09f80d30062952d897733b8761fcfe80f
# EXP-Topic hgweb-cleanup
hgweb: look up "URLSearchParams" in "window" to work around jshint issues

Unfortunately, current version of jshint (2.9.5) doesn't know such a global
variable and complains that it's undefined. Since this line tries to look up
URLSearchParams in a global scope (i.e. window), let's simply preface it with
"window." to work around jshint.

Patch

diff --git a/mercurial/templates/static/mercurial.js b/mercurial/templates/static/mercurial.js
--- a/mercurial/templates/static/mercurial.js
+++ b/mercurial/templates/static/mercurial.js
@@ -451,7 +451,7 @@  function renderDiffOptsForm() {
         "ignoreblanklines",
     ];
 
-    var urlParams = new URLSearchParams(window.location.search);
+    var urlParams = new window.URLSearchParams(window.location.search);
 
     function updateAndRefresh(e) {
         var checkbox = e.target;