diff options
Diffstat (limited to 'app/assets/javascripts/line_highlighter.js')
-rw-r--r-- | app/assets/javascripts/line_highlighter.js | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/app/assets/javascripts/line_highlighter.js b/app/assets/javascripts/line_highlighter.js index dd868bb9f4c..ed10c7646a8 100644 --- a/app/assets/javascripts/line_highlighter.js +++ b/app/assets/javascripts/line_highlighter.js @@ -1,4 +1,4 @@ -/* eslint-disable func-names, no-underscore-dangle, no-param-reassign, consistent-return, no-else-return */ +/* eslint-disable func-names, no-underscore-dangle, no-param-reassign, consistent-return */ import $ from 'jquery'; @@ -54,6 +54,7 @@ LineHighlighter.prototype.bindEvents = function() { $fileHolder.on('click', 'a[data-line-number]', this.clickHandler); $fileHolder.on('highlight:line', this.highlightHash); + window.addEventListener('hashchange', e => this.highlightHash(e.target.location.hash)); }; LineHighlighter.prototype.highlightHash = function(newHash) { @@ -127,9 +128,8 @@ LineHighlighter.prototype.hashToRange = function(hash) { const first = parseInt(matches[1], 10); const last = matches[2] ? parseInt(matches[2], 10) : null; return [first, last]; - } else { - return [null, null]; } + return [null, null]; }; // Highlight a single line @@ -152,9 +152,8 @@ LineHighlighter.prototype.highlightRange = function(range) { } return results; - } else { - return this.highlightLine(range[0]); } + return this.highlightLine(range[0]); }; // Set the URL hash string |