summaryrefslogtreecommitdiff
path: root/source/features/extend-diff-expander.tsx
blob: f6006113361507a8ffd65a002bfccd5e53e2f646 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import './extend-diff-expander.css';
import select from 'select-dom';
import delegate from 'delegate-it';
import * as pageDetect from 'github-url-detection';

import features from '.';

function expandDiff(event: delegate.Event): void {
	// Skip if the user clicked directly on the icon
	if (!(event.target as Element).closest('.js-expand')) {
		select('.js-expand', event.delegateTarget)!.click();
	}
}

function init(): void {
	delegate(document, '.diff-view .js-expandable-line', 'click', expandDiff);
}

void features.add(__filebasename, {
	include: [
		pageDetect.isPRFiles,
		pageDetect.isCommit
	],
	init
});