Skip to content

Commit 6a9789b

Browse files
davidfan168Aeolun
authored andcommitted
Revert "refactoring attempt"
This reverts commit 45b11f9.
1 parent de957c3 commit 6a9789b

File tree

2 files changed

+22
-34
lines changed

2 files changed

+22
-34
lines changed

src/index.tsx

Lines changed: 22 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,28 @@ class DiffViewer extends React.Component<
589589
};
590590
};
591591

592-
private calculateColSpans = (hideLineNumbers : boolean) => {
592+
public render = (): ReactElement => {
593+
const {
594+
oldValue,
595+
newValue,
596+
useDarkTheme,
597+
leftTitle,
598+
rightTitle,
599+
splitView,
600+
compareMethod,
601+
hideLineNumbers,
602+
nonce,
603+
} = this.props;
604+
605+
if (typeof(compareMethod) === 'string' && compareMethod !== DiffMethod.JSON) {
606+
if (typeof oldValue !== 'string' || typeof newValue !== 'string') {
607+
throw Error('"oldValue" and "newValue" should be strings');
608+
}
609+
}
610+
611+
this.styles = this.computeStyles(this.props.styles, useDarkTheme, nonce);
612+
const nodes = this.renderDiff();
613+
593614
let colSpanOnSplitView = 3;
594615
let colSpanOnInlineView = 4;
595616

@@ -603,10 +624,6 @@ class DiffViewer extends React.Component<
603624
colSpanOnInlineView += 1;
604625
}
605626

606-
return [colSpanOnSplitView, colSpanOnInlineView]
607-
}
608-
609-
private calculateChanges = (nodes) => {
610627
let deletions = 0, additions = 0
611628
nodes.lineInformation.forEach((l) => {
612629
if (l.left.type === DiffType.ADDED) {
@@ -622,34 +639,6 @@ class DiffViewer extends React.Component<
622639
deletions++
623640
}
624641
})
625-
return [deletions, additions]
626-
}
627-
628-
public render = (): ReactElement => {
629-
const {
630-
oldValue,
631-
newValue,
632-
useDarkTheme,
633-
leftTitle,
634-
rightTitle,
635-
splitView,
636-
compareMethod,
637-
hideLineNumbers,
638-
nonce,
639-
} = this.props;
640-
641-
if (typeof(compareMethod) === 'string' && compareMethod !== DiffMethod.JSON) {
642-
if (typeof oldValue !== 'string' || typeof newValue !== 'string') {
643-
throw Error('"oldValue" and "newValue" should be strings');
644-
}
645-
}
646-
647-
this.styles = this.computeStyles(this.props.styles, useDarkTheme, nonce);
648-
const nodes = this.renderDiff();
649-
650-
const [colSpanOnSplitView, colSpanOnInlineView] = this.calculateColSpans(hideLineNumbers)
651-
652-
const [deletions, additions] = this.calculateChanges(nodes)
653642
const totalChanges = deletions + additions
654643

655644
const percentageAddition = Math.round((additions / totalChanges) * 100)

tsconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"experimentalDecorators": true,
44
"jsx": "react-jsx",
55
"module": "commonjs",
6-
"strict": true,
76
"moduleResolution": "node",
87
"noImplicitAny": true,
98
"esModuleInterop": true,

0 commit comments

Comments
 (0)