Skip to content

Commit

Permalink
refactor: use textContent instead of getText (hexojs#272)
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshinorin authored and nevilm-lt committed Apr 22, 2022
1 parent e39c897 commit af35d61
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/toc_obj.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ function tocObj(str, options = {}) {
const unnumbered = isUnnumbered(el);
let text = '';
for (const element of el.children) {
const elText = DomUtils.getText(element);
const elText = DomUtils.textContent(element);
// Skip permalink symbol wrapped in <a>
// permalink is a single non-word character, word = [a-Z0-9]
// permalink may be wrapped in whitespace(s)
if (element.name !== 'a' || !nonWord.test(elText)) {
text += escapeHTML(elText);
}
}
if (!text) text = escapeHTML(DomUtils.getText(el));
if (!text) text = escapeHTML(DomUtils.textContent(el));

const res = { text, id, level };
if (unnumbered) res.unnumbered = true;
Expand Down

0 comments on commit af35d61

Please sign in to comment.