Commit e74df4c3 authored by Tom Quirk's avatar Tom Quirk

Select todo count with js-todos-count everywhere

parent 22daea99
...@@ -52,7 +52,7 @@ export default { ...@@ -52,7 +52,7 @@ export default {
}, },
methods: { methods: {
updateToDoCount(add) { updateToDoCount(add) {
const oldCount = parseInt(document.querySelector('.todos-count').innerText, 10); const oldCount = parseInt(document.querySelector('.js-todos-count').innerText, 10);
const count = add ? oldCount + 1 : oldCount - 1; const count = add ? oldCount + 1 : oldCount - 1;
const headerTodoEvent = new CustomEvent('todo:toggle', { const headerTodoEvent = new CustomEvent('todo:toggle', {
detail: { detail: {
......
...@@ -14,7 +14,7 @@ import Tracking from '~/tracking'; ...@@ -14,7 +14,7 @@ import Tracking from '~/tracking';
export default function initTodoToggle() { export default function initTodoToggle() {
$(document).on('todo:toggle', (e, count) => { $(document).on('todo:toggle', (e, count) => {
const updatedCount = count || e?.detail?.count || 0; const updatedCount = count || e?.detail?.count || 0;
const $todoPendingCount = $('.todos-count'); const $todoPendingCount = $('.js-todos-count');
$todoPendingCount.text(highCountTrim(updatedCount)); $todoPendingCount.text(highCountTrim(updatedCount));
$todoPendingCount.toggleClass('hidden', updatedCount === 0); $todoPendingCount.toggleClass('hidden', updatedCount === 0);
......
...@@ -4,7 +4,7 @@ import initTodoToggle, { initNavUserDropdownTracking } from '~/header'; ...@@ -4,7 +4,7 @@ import initTodoToggle, { initNavUserDropdownTracking } from '~/header';
describe('Header', () => { describe('Header', () => {
describe('Todos notification', () => { describe('Todos notification', () => {
const todosPendingCount = '.todos-count'; const todosPendingCount = '.js-todos-count';
const fixtureTemplate = 'issues/open-issue.html'; const fixtureTemplate = 'issues/open-issue.html';
function isTodosCountHidden() { function isTodosCountHidden() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment