Skip to content

fix(preload): resolve anchor hrefs against document.baseURI - #706

Merged
ryansolid merged 1 commit into
nextfrom
claude/project-thread-fdizuj-704
Oct 28, 2026
Merged

ryansolid merged 1 commit into
nextfrom
claude/project-thread-fdizuj-704

Conversation

@ryansolid

Copy link
Copy Markdown
Member

Fixes #704.

Problem

anchorUrl built HTML anchors' URLs with new URL(a.href) and no base. Solid clones compiled nodes from a <template>. Until a clone is adopted into the page, its href property is the raw attribute (/about). When eagerPreload's idle flush reached such an anchor, for example one a transition was still holding off the page, it threw an uncaught Invalid URL.

Change

anchorUrl now resolves every anchor against document.baseURI, the same way it already handled SVG anchors. An anchor already in the page has an absolute href, so the base changes nothing for it. A clone resolves to the URL it will have once it is adopted, so it preloads correctly. Dropping the HTML/SVG branch makes the client bundle slightly smaller.

Tests

  • New case in test/data/events.spec.ts: an anchor cloned from a template is claimed under eagerPreload({ all: true }) and flushed before it is adopted. Without the fix it fails with TypeError: Invalid URL; with the fix it preloads /a.
  • pnpm test passes (724 client, 102 server), as do pnpm test:types and prettier.

Generated by Claude Code

An anchor cloned from a <template> keeps its raw href until it is
adopted into the page, so eagerPreload's idle flush threw Invalid URL
on one a transition still held off the page.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0117BoWNQHxQ9311k7tQMEKs
@changeset-bot

changeset-bot Bot commented Oct 28, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 7488be9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@solidjs/router Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@ryansolid
ryansolid merged commit 036a947 into next Oct 28, 2026
4 checks passed
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.

2 participants