Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/gh_comments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ pub async fn gh_comments(
details.open = false;
}});
}});
document.getElementById('gh-comments-reverse-toc-order-btn').addEventListener('click', () => {{
document.getElementById('gh-comments-reverse-toc-order-btn')?.addEventListener('click', () => {{
var tocList = document.getElementById('toc-list');
for (var i = 1; i < tocList.childNodes.length; i++) {{
tocList.insertBefore(tocList.childNodes[i], tocList.firstChild);
Expand Down
14 changes: 12 additions & 2 deletions src/gh_comments/self_contained.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ document.addEventListener('DOMContentLoaded', function() {
triggerUserDownload(htmlContent, `gh-comments-${ISSUE_ID}-export-${new Date().toISOString().slice(0,10)}.html`);
} catch (e) {
console.log(e);
alert(`Error: ${e.message}`);
if (e instanceof Error) {
alert(`Unable to export the comments: ${e}`);
} else {
alert(`Unable to export the comments. See the console for more details.`);
}
}
});
});
Expand Down Expand Up @@ -83,7 +87,13 @@ async function inlineImages(doc) {
canvas.getContext('2d').drawImage(tempImg, 0, 0, canvas.width, canvas.height);
resolve(canvas.toDataURL('image/png'));
};
tempImg.onerror = reject;
tempImg.onerror = (event) => {
// We got an error, probably a CORS rejection (happens with user images on GitHub), but we
// can't be certain. We only get an event, not an error.
//
// Anyway, let's ignore this error and use the initial source.
resolve(src);
};
tempImg.src = src;
});
}));
Expand Down