🐛 Fix new comment dropdown issue (#13661)

This commit is contained in:
Andrew Bone 2021-05-06 14:06:30 +01:00 committed by GitHub
parent c5ca92e289
commit 2a05955092
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -556,9 +556,16 @@ function listenForDetailsToggle() {
}
}
/**
* Increment comment, stored in `.js-comments-count`, count by one.
*/
function updateCommentsCount() {
var commentsCountDiv = document.getElementsByClassName("js-comments-count")[0];
var commentsCountData = parseInt(commentsCountDiv.dataset.commentsCount) + 1;
const commentsCountDiv = document.querySelector(".js-comments-count");
// if there's nowhere to put the count return early.
if(!commentsCountDiv) return;
const commentsCountData = parseInt(commentsCountDiv.dataset.commentsCount, 10) + 1;
commentsCountDiv.dataset.commentsCount = commentsCountData;
commentsCountDiv.innerHTML = `(${commentsCountData})`
}