Patchwork [STABLE] hgweb: prevent triggering dummy href="#" handler

login
register
mail settings
Submitter Yuya Nishihara
Date May 3, 2018, 5:51 a.m.
Message ID <387af9e5df701db8e6d4.1525326709@mimosa>
Download mbox | patch
Permalink /patch/31262/
State Accepted
Headers show

Comments

Yuya Nishihara - May 3, 2018, 5:51 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1525326205 -32400
#      Thu May 03 14:43:25 2018 +0900
# Branch stable
# Node ID 387af9e5df701db8e6d411a7fde6c946ebcc59b3
# Parent  82ae4f4712543b4a83ede2cbbf1553948b66999d
hgweb: prevent triggering dummy href="#" handler

Follow up for the previous patch.

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
@@ -328,14 +328,15 @@  function process_dates(parentSelector){
 	}
 }
 
-function toggleDiffstat() {
+function toggleDiffstat(event) {
     var curdetails = document.getElementById('diffstatdetails').style.display;
     var curexpand = curdetails === 'none' ? 'inline' : 'none';
     document.getElementById('diffstatdetails').style.display = curexpand;
     document.getElementById('diffstatexpand').style.display = curdetails;
+    event.preventDefault();
 }
 
-function toggleLinewrap() {
+function toggleLinewrap(event) {
     function getLinewrap() {
         var nodes = document.getElementsByClassName('sourcelines');
         // if there are no such nodes, error is thrown here
@@ -360,6 +361,7 @@  function toggleLinewrap() {
     }
 
     setLinewrap(!getLinewrap());
+    event.preventDefault();
 }
 
 function format(str, replacements) {