parseHeader in src/components/java/patch-notes.tsx de-duplicates generated heading ids, but writes the counter under the already-suffixed id instead of the base id:
let id = toKebabCase(headingText);
const dups = ids.get(id) ?? 0;
if (dups > 0) {
id += `-${dups}`;
}
ids.set(id, dups + 1); // <-- `id` has already been reassigned
So the base id's counter never advances past 1:
| occurrence |
dups read |
id emitted |
counter written |
| 1st |
0 (parameters) |
parameters |
parameters → 1 |
| 2nd |
1 (parameters) |
parameters-1 |
parameters-1 → 2 |
| 3rd |
1 (parameters) |
parameters-1 |
parameters-1 → 2 |
Every occurrence from the third onward collides on -1.
Impact. Duplicate DOM ids, so the table-of-contents anchor links for the affected headings all jump to the same place. Measured across all 403 articles in the v2 manifest: 7 articles emit literally duplicate ids, worst case 1.14, which emits parameters-1 ten times.
Fix. Key the counter on the base id:
const base = toKebabCase(headingText);
const dups = ids.get(base) ?? 0;
const id = dups > 0 ? `${base}-${dups}` : base;
ids.set(base, dups + 1);
Note this still can't guarantee uniqueness against a heading whose literal text is Parameters 1, so consider a uniqueness check on the final id.
Found while researching #36 (annotation anchoring) — heading-derived ids were being evaluated as an anchor selector and rejected partly because of this. Filing separately because it is a live bug in the rendered page today, independent of that work.
parseHeaderinsrc/components/java/patch-notes.tsxde-duplicates generated heading ids, but writes the counter under the already-suffixed id instead of the base id:So the base id's counter never advances past 1:
dupsreadparameters)parametersparameters→ 1parameters)parameters-1parameters-1→ 2parameters)parameters-1parameters-1→ 2Every occurrence from the third onward collides on
-1.Impact. Duplicate DOM ids, so the table-of-contents anchor links for the affected headings all jump to the same place. Measured across all 403 articles in the v2 manifest: 7 articles emit literally duplicate ids, worst case
1.14, which emitsparameters-1ten times.Fix. Key the counter on the base id:
Note this still can't guarantee uniqueness against a heading whose literal text is
Parameters 1, so consider a uniqueness check on the final id.Found while researching #36 (annotation anchoring) — heading-derived ids were being evaluated as an anchor selector and rejected partly because of this. Filing separately because it is a live bug in the rendered page today, independent of that work.