Commit 8ffb3de5 authored by Martin Wortschack's avatar Martin Wortschack

Merge branch 'ph/213212/hashChangeForBlobs' into 'master'

Fixes blob view not updating highlighted line after hash change

Closes #213212

See merge request gitlab-org/gitlab!28686
parents 315adb23 faf0f639
......@@ -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) {
......
......@@ -67,6 +67,16 @@ describe('LineHighlighter', function() {
expect(func).not.toThrow();
});
it('handles hashchange event', () => {
const highlighter = new LineHighlighter();
spyOn(highlighter, 'highlightHash');
window.dispatchEvent(new Event('hashchange'), 'L15');
expect(highlighter.highlightHash).toHaveBeenCalled();
});
});
describe('clickHandler', function() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment