diff --git a/lib/plugins/helper/toc.js b/lib/plugins/helper/toc.js index 01aa7c9fbf..52b5f28481 100644 --- a/lib/plugins/helper/toc.js +++ b/lib/plugins/helper/toc.js @@ -32,7 +32,9 @@ function tocHelper(str, options = {}) { return id || (parent.length < 1 ? null : getId(parent)); } - for (const el of headings) { + const headingLen = headings.length; + for (let i = 0; i < headingLen; i++) { + const el = headings[i]; const level = +el.name[1]; const id = getId(el); const text = escapeHTML(DomUtils.getText(el));