Skip to content

Commit

Permalink
Merge pull request #96 from berzniz/fix_github_changes
Browse files Browse the repository at this point in the history
Update due to GitHub DOM changes close #95 #94
  • Loading branch information
berzniz authored Feb 27, 2020
2 parents a4fc0c7 + 2b0e726 commit 71f0dc0
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 36 deletions.
26 changes: 13 additions & 13 deletions src/js/__tests__/fixtures/pr.html
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,7 @@ <h4 class="mb-2 mt-3">Just for now</h4>
<div class="js-diff-progressive-container">

<a name="diff-a9c08afc9ba1304a73e4235b3016b97c"></a>
<div id="diff-0" class="file js-file js-details-container Details
<div id="diff-a9c08afc9ba1304a73e4235b3016b97c" class="file js-file js-details-container Details
Details--on open


Expand Down Expand Up @@ -1544,7 +1544,7 @@ <h4 class="mb-2 mt-3">Just for now</h4>


<a name="diff-d917dafee00f70f932bbee5f65d6f2a0"></a>
<div id="diff-1" class="file js-file js-details-container Details
<div id="diff-d917dafee00f70f932bbee5f65d6f2a0" class="file js-file js-details-container Details
Details--on open


Expand Down Expand Up @@ -3854,7 +3854,7 @@ <h4 class="mb-2 mt-3">Just for now</h4>


<a name="diff-e1ed11a9f728e656700a09c5e5b8421a"></a>
<div id="diff-2" class="file js-file js-details-container Details
<div id="diff-e1ed11a9f728e656700a09c5e5b8421a" class="file js-file js-details-container Details
Details--on open


Expand Down Expand Up @@ -6311,7 +6311,7 @@ <h4 class="mb-2 mt-3">Just for now</h4>
<div class="js-diff-progressive-container">

<a name="diff-704a99ac64ff37ffb3c4ab785c086e0a"></a>
<div id="diff-3" class="file js-file js-details-container Details
<div id="diff-704a99ac64ff37ffb3c4ab785c086e0a" class="file js-file js-details-container Details
Details--on open


Expand Down Expand Up @@ -11482,7 +11482,7 @@ <h4 class="mb-2 mt-3">Just for now</h4>


<a name="diff-904ceabd8a1e9a07ab1d876d843d62e1"></a>
<div id="diff-4" class="file js-file js-details-container Details
<div id="diff-904ceabd8a1e9a07ab1d876d843d62e1" class="file js-file js-details-container Details
Details--on open


Expand Down Expand Up @@ -11644,7 +11644,7 @@ <h4 class="mb-2 mt-3">Just for now</h4>


<a name="diff-5909cd216fb0ff82eee4189e8ef7b1f7"></a>
<div id="diff-5" class="file js-file js-details-container Details
<div id="diff-5909cd216fb0ff82eee4189e8ef7b1f7" class="file js-file js-details-container Details
Details--on open


Expand Down Expand Up @@ -11828,7 +11828,7 @@ <h4 class="mb-2 mt-3">Just for now</h4>


<a name="diff-67a3dce2da4d4c98b273a5ffbed4ecf3"></a>
<div id="diff-6" class="file js-file js-details-container Details
<div id="diff-67a3dce2da4d4c98b273a5ffbed4ecf3" class="file js-file js-details-container Details
Details--on open


Expand Down Expand Up @@ -12012,7 +12012,7 @@ <h4 class="mb-2 mt-3">Just for now</h4>


<a name="diff-0acba6beb8dfb7ac3a890e04f9330672"></a>
<div id="diff-7" class="file js-file js-details-container Details
<div id="diff-0acba6beb8dfb7ac3a890e04f9330672" class="file js-file js-details-container Details
Details--on open


Expand Down Expand Up @@ -12174,7 +12174,7 @@ <h4 class="mb-2 mt-3">Just for now</h4>


<a name="diff-59d412cdab2cee911e8048f2274d7714"></a>
<div id="diff-8" class="file js-file js-details-container Details
<div id="diff-59d412cdab2cee911e8048f2274d7714" class="file js-file js-details-container Details
Details--on open


Expand Down Expand Up @@ -12358,7 +12358,7 @@ <h4 class="mb-2 mt-3">Just for now</h4>


<a name="diff-ca01894737d09fe21db1236f67674978"></a>
<div id="diff-9" class="file js-file js-details-container Details
<div id="diff-ca01894737d09fe21db1236f67674978" class="file js-file js-details-container Details
Details--on open


Expand Down Expand Up @@ -12542,7 +12542,7 @@ <h4 class="mb-2 mt-3">Just for now</h4>


<a name="diff-b3f99b384357abacceae9c7f5babef83"></a>
<div id="diff-10" class="file js-file js-details-container Details
<div id="diff-b3f99b384357abacceae9c7f5babef83" class="file js-file js-details-container Details
Details--on open


Expand Down Expand Up @@ -12726,7 +12726,7 @@ <h4 class="mb-2 mt-3">Just for now</h4>


<a name="diff-674daeb2e5d6f787b0acb4ad821fbc45"></a>
<div id="diff-11" class="file js-file js-details-container Details
<div id="diff-674daeb2e5d6f787b0acb4ad821fbc45" class="file js-file js-details-container Details
Details--on open


Expand Down Expand Up @@ -12910,7 +12910,7 @@ <h4 class="mb-2 mt-3">Just for now</h4>


<a name="diff-228079017fb840664ef2da2a2dfed166"></a>
<div id="diff-12" class="file js-file js-details-container Details
<div id="diff-228079017fb840664ef2da2a2dfed166" class="file js-file js-details-container Details
Details--on open


Expand Down
2 changes: 1 addition & 1 deletion src/js/__tests__/fixtures/pr_with_comment.html
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,7 @@ <h4 class="mb-2 mt-3">Just for now</h4>
<div class="js-diff-progressive-container">

<a name="diff-1fa94200dd7ba6669fbf56bcec30e78e"></a>
<div id="diff-0" class="file js-file js-details-container Details
<div id="diff-1fa94200dd7ba6669fbf56bcec30e78e" class="file js-file js-details-container Details
Details--on open
Expand Down
28 changes: 14 additions & 14 deletions src/js/__tests__/fixtures/pr_with_deletion.html
Original file line number Diff line number Diff line change
Expand Up @@ -1016,7 +1016,7 @@ <h4 class="mb-2 mt-3">Just for now</h4>
<div class="js-diff-progressive-container">

<a name="diff-ae9eba3500703eaba1d5b8e13832d955"></a>
<div id="diff-0" class="file js-file js-details-container Details
<div id="diff-ae9eba3500703eaba1d5b8e13832d955" class="file js-file js-details-container Details
Details--on open


Expand Down Expand Up @@ -1119,7 +1119,7 @@ <h4 class="mb-2 mt-3">Just for now</h4>


<a name="diff-b9cfc7f2cdf78a7f4b91a753d10865a2"></a>
<div id="diff-1" class="file js-file js-details-container Details
<div id="diff-b9cfc7f2cdf78a7f4b91a753d10865a2" class="file js-file js-details-container Details
Details--on open


Expand Down Expand Up @@ -1753,7 +1753,7 @@ <h4 class="mb-2 mt-3">Just for now</h4>


<a name="diff-dd6e1634f708d0c3e1695c1a73eae8c5"></a>
<div id="diff-2" class="file js-file js-details-container Details
<div id="diff-dd6e1634f708d0c3e1695c1a73eae8c5" class="file js-file js-details-container Details
Details--on open


Expand Down Expand Up @@ -1957,7 +1957,7 @@ <h4 class="mb-2 mt-3">Just for now</h4>


<a name="diff-c5453c501251b48888b4a9b15ff55ae1"></a>
<div id="diff-3" class="file js-file js-details-container Details
<div id="diff-c5453c501251b48888b4a9b15ff55ae1" class="file js-file js-details-container Details
Details--on open


Expand Down Expand Up @@ -5197,7 +5197,7 @@ <h4 class="mb-2 mt-3">Just for now</h4>


<a name="diff-6c6554c881731a0c8ac33c8ddba3876e"></a>
<div id="diff-4" class="file js-file js-details-container Details
<div id="diff-6c6554c881731a0c8ac33c8ddba3876e" class="file js-file js-details-container Details
Details--on open


Expand Down Expand Up @@ -5640,7 +5640,7 @@ <h4 class="mb-2 mt-3">Just for now</h4>


<a name="diff-a80d4a080b86fc064e97b4628cb8b7f7"></a>
<div id="diff-5" class="file js-file js-details-container Details
<div id="diff-a80d4a080b86fc064e97b4628cb8b7f7" class="file js-file js-details-container Details
Details--on open


Expand Down Expand Up @@ -5967,7 +5967,7 @@ <h4 class="mb-2 mt-3">Just for now</h4>


<a name="diff-89c61a882bbd0c44a6a041446416c56b"></a>
<div id="diff-6" class="file js-file js-details-container Details
<div id="diff-89c61a882bbd0c44a6a041446416c56b" class="file js-file js-details-container Details
Details--on open


Expand Down Expand Up @@ -6345,7 +6345,7 @@ <h4 class="mb-2 mt-3">Just for now</h4>


<a name="diff-766f7deb700902b33c2fe1ec4cd8f4e2"></a>
<div id="diff-7" class="file js-file js-details-container Details
<div id="diff-766f7deb700902b33c2fe1ec4cd8f4e2" class="file js-file js-details-container Details
Details--on open


Expand Down Expand Up @@ -6437,7 +6437,7 @@ <h4 class="mb-2 mt-3">Just for now</h4>
<div class="js-diff-progressive-container">

<a name="diff-7a4b1c45d0fef2bb9fa773a2942c4080"></a>
<div id="diff-8" class="file js-file js-details-container Details
<div id="diff-7a4b1c45d0fef2bb9fa773a2942c4080" class="file js-file js-details-container Details
Details--on open


Expand Down Expand Up @@ -6526,7 +6526,7 @@ <h4 class="mb-2 mt-3">Just for now</h4>


<a name="diff-b1993135160f715a8bd3428ad27c24e8"></a>
<div id="diff-9" class="file js-file js-details-container Details
<div id="diff-b1993135160f715a8bd3428ad27c24e8" class="file js-file js-details-container Details
Details--on open


Expand Down Expand Up @@ -6710,7 +6710,7 @@ <h4 class="mb-2 mt-3">Just for now</h4>


<a name="diff-24c1db6dce18cb15d6f7715d8e5c774a"></a>
<div id="diff-10" class="file js-file js-details-container Details
<div id="diff-24c1db6dce18cb15d6f7715d8e5c774a" class="file js-file js-details-container Details
Details--on open


Expand Down Expand Up @@ -7555,7 +7555,7 @@ <h4 class="mb-2 mt-3">Just for now</h4>


<a name="diff-82f17d15995c74879a30bf88b427405b"></a>
<div id="diff-11" class="file js-file js-details-container Details
<div id="diff-82f17d15995c74879a30bf88b427405b" class="file js-file js-details-container Details
Details--on open


Expand Down Expand Up @@ -8143,7 +8143,7 @@ <h4 class="mb-2 mt-3">Just for now</h4>


<a name="diff-ec54a28b230bc1bbf66afcc85a0a5451"></a>
<div id="diff-12" class="file js-file js-details-container Details
<div id="diff-ec54a28b230bc1bbf66afcc85a0a5451" class="file js-file js-details-container Details
Details--on open


Expand Down Expand Up @@ -8386,7 +8386,7 @@ <h4 class="mb-2 mt-3">Just for now</h4>


<a name="diff-8ee2343978836a779dc9f8d6b794c3b2"></a>
<div id="diff-13" class="file js-file js-details-container Details
<div id="diff-8ee2343978836a779dc9f8d6b794c3b2" class="file js-file js-details-container Details
Details--on open


Expand Down
18 changes: 10 additions & 8 deletions src/js/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,17 @@ const getDiffStatsForDiffElement = (diffElement) => {
}
}

const hasCommentsForFileIndex = (fileIndex) => {
const diffTable = document.getElementById(`diff-${fileIndex}`)
const hasCommentsForFileId = (fileId) => {
const diffTable = document.getElementById(fileId)
if (!diffTable) {
return 0
}

return diffTable.querySelectorAll('.inline-comments').length
}

const isDeletedForFileIndex = (fileIndex) => {
const diffTable = document.getElementById(`diff-${fileIndex}`)
const isDeletedForFileId = (fileId) => {
const diffTable = document.getElementById(fileId)
if (!diffTable) {
return false
}
Expand Down Expand Up @@ -111,15 +111,17 @@ export const createFileTree = (filter = EMPTY_FILTER) => {
diffElements: []
}

files.forEach(({ parts, href }, fileIndex) => {
files.forEach(({ parts, href }) => {
let location = tree
if (filterItem(parts[parts.length - 1], filter)) {
parts.forEach((part, index) => {
let node = location.list.find(node => node.nodeLabel === part)
if (!node) {
const hasComments = (hasCommentsForFileIndex(fileIndex) > 0)
const isDeleted = isDeletedForFileIndex(fileIndex)
const diffElement = document.getElementById(`diff-${fileIndex}`)
const hrefSplit = href.split('#')
const fileId = hrefSplit[hrefSplit.length - 1]
const hasComments = (hasCommentsForFileId(fileId) > 0)
const isDeleted = isDeletedForFileId(fileId)
const diffElement = document.getElementById(fileId)
tree.diffElements.push(diffElement)
node = {
nodeLabel: part,
Expand Down

0 comments on commit 71f0dc0

Please sign in to comment.