diff --git a/src/client/app/common/views/components/mfm.ts b/src/client/app/common/views/components/mfm.ts index 31d5d1660..a6487aa4f 100644 --- a/src/client/app/common/views/components/mfm.ts +++ b/src/client/app/common/views/components/mfm.ts @@ -16,15 +16,8 @@ function getTextCount(tokens: Node[]): number { } function getChildrenCount(tokens: Node[]): number { - let count = 0; - const extract = (tokens: Node[]) => { - tokens.filter(x => x.children).forEach(x => { - count++; - extract(x.children); - }); - }; - extract(tokens); - return count; + const countTree = tokens.filter(x => x.children).map(x => getChildrenCount(x.children)); + return countTree.length + sum(countTree); } export default Vue.component('misskey-flavored-markdown', {