Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fix: Code-owner links are breaking the extension #113

Merged
merged 4 commits into from
May 1, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions src/js/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,12 @@ const getDiffElement = (fileId) => {
return el
}

const gitHubEnterpriseEl = document.querySelector(`[data-anchor="${fileId}"]`).parentElement
return gitHubEnterpriseEl
const gitHubEnterpriseEl = document.querySelector(`[data-anchor="${fileId}"]`)
if (gitHubEnterpriseEl) {
return gitHubEnterpriseEl.parentElement
}

return null
}

const countCommentsForFileId = (fileId) => {
Expand Down Expand Up @@ -129,9 +133,13 @@ export const createFileTree = (filter = EMPTY_FILTER) => {
if (!node) {
const hrefSplit = href.split('#')
const fileId = hrefSplit[hrefSplit.length - 1]
const diffElement = getDiffElement(fileId)
if (!diffElement) {
return
}

const hasComments = (countCommentsForFileId(fileId) > 0)
const isDeleted = isDeletedForFileId(fileId)
const diffElement = getDiffElement(fileId)
tree.diffElements.push(diffElement)
node = {
nodeLabel: part,
Expand Down Expand Up @@ -177,9 +185,9 @@ const EMPTY_FILTER = ''

export const getBrowserApi = () => {
let browserApi = window.chrome
if (typeof browser !== 'undefined') {
browserApi = browser
}
if (typeof browser !== 'undefined') {
browserApi = browser
}
return browserApi
}

Expand Down