Skip to content

fix(rules): links/broken-anchors flags script-named ids as unconfirmed on unrendered pages (#1616) - #1620

Closed
nc9 wants to merge 2 commits into
mainfrom
fix/broken-anchors-runtime-ids-1616
Closed

nc9 wants to merge 2 commits into
mainfrom
fix/broken-anchors-runtime-ids-1616

Conversation

@nc9

@nc9 nc9 commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

What

In HTTP-only mode a server-rendered page can create a target id from inline script at init (el.id = "size"). The id is not in the fetched HTML, so links/broken-anchors reported the link as definitely broken, although a browser resolves it.

The per-page anchor record now keeps the quoted id-like tokens from a page's inline code scripts (only when the page was not rendered; capped at 256 distinct tokens and 256 KB of script text, bounded and detached like the other record fields). A missing fragment that such a script names is reported under unconfirmed-anchors (info). If the scripts were over a cap, no missing id on that page is confirmed.

  • A missing id no script names still warns. A static id still passes.
  • Rendered audits are unchanged: the initialized DOM is read, so a runtime id passes and a missing one fails.
  • JSON-LD, import maps and template scripts are not read. An id built by concatenation or created by an external script file is not named in the HTML, so an unrendered audit still reports it as broken; the docs say so.
  • The unconfirmed-anchors message no longer says "client-rendered page" (it now covers server-rendered pages): "target a page that was not rendered and may add the id with JavaScript".

Tests

packages/rules/tests/broken-anchors.test.ts, both engines (DOM and streaming collector): script-set id unconfirmed, missing still warns, static passes, id inside an HTML string, cross-page link, data scripts ignored, rendered mode, oversized script. Also ran collected-signals-retention-1565, single-page-site, link-sources-837, docs-rule-pages, the audit-engine broken-anchors and canonical goldens, make validate, oxlint, tsgo on packages/rules. Fixtures use invented text.

CHANGELOG bullet under Unreleased; docs/rules/links/broken-anchors.mdx updated. The squirrelscan agent skill does not need a change.

Closes #1616

nc9 added 2 commits November 7, 2026 11:18
… as unconfirmed, not broken, on unrendered pages #1616

Signed-off-by: Nik Cubrilovic <[email protected]>
…emotes nothing; 1024 tokens of 64 chars; docs say name match #1616

Signed-off-by: Nik Cubrilovic <[email protected]>
@nc9

nc9 commented Nov 7, 2026

Copy link
Copy Markdown
Contributor Author

Landed via #1624 (rebase-merged, commits on main from f6787b4 to f2775ee: 902f93a and f6787b4 for #1617, 2361aa4 and ce40f50 for #1616, 383183e, 04e984e, 0f79f70 for #1615). Closing this draft as superseded.

nik

@nc9 nc9 closed this Nov 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

links/broken-anchors overstates certainty for runtime-created IDs in HTTP-only server-rendered pages

1 participant