Skip to content

fix(link): isolate per-link target overrides - #2818

Open
xu91102 wants to merge 2 commits into
docsifyjs:developfrom
xu91102:fix/link-target-isolation
Open

xu91102 wants to merge 2 commits into
docsifyjs:developfrom
xu91102:fix/link-target-isolation

Conversation

@xu91102

@xu91102 xu91102 commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

Summary

A link with :target=_self changes the target of subsequent ordinary external links to _self, even though the configured default is _blank. The link renderer mutates linkTarget captured by its closure, so one link's override becomes the next link's default.

Compute target and rel locally for each rendered link. Three regression cases cover overrides on external, relative, and mailto links followed by an ordinary external link.

Example: [First](https://example.org/first ':target=_self') followed by [Second](https://example.org/second) now keeps the second link's default _blank target and noopener relation.

Related issue, if any:

Reproduced on develop at d823dbe51c1b2dea4c2091e2b952ded0d1e16616; no matching open fix found.

What kind of change does this PR introduce?

  • Bugfix

For any code change,

  • Related documentation has been updated, if needed (no public configuration change)
  • Related tests have been added or updated

Does this PR introduce a breaking change?

  • No

Validation

  • All three new regressions failed before the fix with _self instead of _blank.
  • npm run test:jest -- --runInBand: 131 tests and 46 snapshots passed.
  • npm run build, npm run lint, npm run typecheck, and git diff --check: passed.
  • Independent read-only review: no required changes.

The regression uses the existing JSDOM integration renderer. Browser E2E was not run for this patch.

Developed with assistance from OpenAI Codex; regression and fix validated locally.

@vercel

vercel Bot commented Sep 28, 2026

Copy link
Copy Markdown

Someone is attempting to deploy a commit to the Docsify Team on Vercel.

A member of the Team first needs to authorize it.

This branch has not been deployed

No deployments
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.

1 participant