Fix TypeError: null is not an object in initializeArticleReactions.js (#9297) [deploy]
* Fix TypeError: null is not an object in initializeArticleReactions.js Should fix https://app.honeybadger.io/fault/67192/6f9b4fdf475e2229c968fa26d785b90f * Return 0 rather than undefined if reactionEl doesn't exist
This commit is contained in:
parent
3391593de1
commit
2fadc24d28
1 changed files with 4 additions and 4 deletions
|
|
@ -40,12 +40,12 @@ function hasUserReacted(reactionName) {
|
|||
}
|
||||
|
||||
function getNumReactions(reactionName) {
|
||||
var num = document.getElementById('reaction-number-' + reactionName)
|
||||
.textContent;
|
||||
if (num === '') {
|
||||
const reactionEl = document.getElementById('reaction-number-' + reactionName);
|
||||
if (!reactionEl || reactionEl.textContent === '') {
|
||||
return 0;
|
||||
}
|
||||
return parseInt(num, 10);
|
||||
|
||||
return parseInt(reactionEl.textContent, 10);
|
||||
}
|
||||
|
||||
function reactToArticle(articleId, reaction) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue