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

Add try/catch loop to prevent glitch on certain pages. #17

Merged
merged 2 commits into from
Apr 11, 2016
Merged
Changes from all commits
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
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