Skip to content

Commit

Permalink
Use textContent instead of innerText
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenjoezhang committed Sep 30, 2020
1 parent 35d1e68 commit 52234e5
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions layout/_third-party/statistics/firestore.njk
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@
const db = firebase.firestore();
const articles = db.collection('{{ theme.firestore.collection }}');

if (CONFIG.page.isPost) { // Is article page
const title = document.querySelector('.post-title').innerText.trim();
if (CONFIG.page.isPost) {
// Fix issue #118
// https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent
const title = document.querySelector('.post-title').textContent.trim();
const doc = articles.doc(title);
let increaseCount = CONFIG.hostname === location.hostname;
if (localStorage.getItem(title)) {
Expand All @@ -55,9 +57,9 @@
localStorage.setItem(title, true);
}
getCount(doc, increaseCount).then(appendCountTo(document.querySelector('.firestore-visitors-count')));
} else if (CONFIG.page.isHome) { // Is index page
} else if (CONFIG.page.isHome) {
const promises = [...document.querySelectorAll('.post-title')].map(element => {
const title = element.innerText.trim();
const title = element.textContent.trim();
const doc = articles.doc(title);
return getCount(doc);
});
Expand Down

0 comments on commit 52234e5

Please sign in to comment.