Skip to content

Commit

Permalink
Merge pull request #17 from Coder-256/master
Browse files Browse the repository at this point in the history
Add try/catch loop to prevent glitch on certain pages.
  • Loading branch information
camsong committed Apr 11, 2016
2 parents 6b25af1 + 65a83e3 commit eef82ca
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function updateOutlinesInPanel() {
var $container = document.createElement('div')
$container.classList.add('github-mate-outline')

Array.from(document.querySelectorAll('.markdown-body')).forEach($md => {
Array.from(document.querySelectorAll('.markdown-body:not(.comment-body):not(.message)')).forEach($md => {
var $headers = Array.from($md.querySelectorAll(headerSel))


Expand Down Expand Up @@ -115,15 +115,19 @@ function updateOutlinesInPanel() {

// find all sublists with one item and replace with contents
Array.from($container.querySelectorAll('ul')).forEach($ul => {
var $parent = $ul.parentNode
var $li = $ul.firstChild
var $child = $li.firstChild
if ($li !== $ul.lastChild || $child.tagName !== 'UL') return
while ($child) {
$parent.insertBefore($child, $ul.nextSibling) // inserts to end of list if $ul.nextSibling is null
$child = $child.nextSibling
try {
var $parent = $ul.parentNode
var $li = $ul.firstChild
var $child = $li.firstChild
if ($li !== $ul.lastChild || $child.tagName !== 'UL') return
while ($child) {
$parent.insertBefore($child, $ul.nextSibling) // inserts to end of list if $ul.nextSibling is null
$child = $child.nextSibling
}
$parent.removeChild($ul)
} catch (e) {
console.log("Error setting up GitHub Mate panel:", e)
}
$parent.removeChild($ul)
})
})

Expand Down

0 comments on commit eef82ca

Please sign in to comment.