Commit 24a3bce
authored
chore: Refactor getHeadingText to remove title parameter (#1707)
getHeadingText passes the current accumulated title as the recursion's second parameter and then concatenates the returned string back onto title:
title += child.value
title += getHeadingText(child.children, title)
Because the recursive call receives the already-accumulated title, the recursive result itself includes that prefix, so the outer concatenation duplicates earlier text (e.g. "A" + "AB" -> "AAB").1 parent 321bfa4 commit 24a3bce
1 file changed
+8
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
| 7 | + | |
7 | 8 | | |
8 | | - | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
9 | 12 | | |
10 | | - | |
| 13 | + | |
11 | 14 | | |
12 | 15 | | |
13 | | - | |
| 16 | + | |
14 | 17 | | |
15 | 18 | | |
16 | 19 | | |
| |||
132 | 135 | | |
133 | 136 | | |
134 | 137 | | |
135 | | - | |
| 138 | + | |
0 commit comments