Skip to content

Make href take precedence over xlink:href - #1080

Merged
LaurenzV merged 6 commits into
linebender:mainfrom
StefanoD:fix/href-precedence-over-xlink
Aug 1, 2026
Merged

Make href take precedence over xlink:href#1080
LaurenzV merged 6 commits into
linebender:mainfrom
StefanoD:fix/href-precedence-over-xlink

Conversation

@StefanoD

Copy link
Copy Markdown
Contributor

SVG 2 requires that when both the unprefixed href and the deprecated xlink:href are present on an element, the value of href is used and the XLink-namespaced attribute is ignored, regardless of source order.

Two code paths were non-compliant:

  • resolve_href (used by <use>) queried xlink:href first and only fell back to href, so xlink:href always won. Note that roxmltree::Node::attribute("href") matches by local name only and ignores the namespace, so the attributes are now filtered explicitly.
  • The generic attribute-copy loop stored both href and xlink:href under AId::Href, and lookups returned whichever came first in document order. The unprefixed href now always wins.

Fixes #1015

Generated by Claude


Note: I accidentally closed the original PR (#1062) by deleting my fork, which auto-closed it. This reopens the same change — the branch and commits are unchanged.

StefanoD and others added 4 commits August 1, 2026 09:57
SVG 2 requires that when both the unprefixed `href` and the deprecated
`xlink:href` are present on an element, the value of `href` is used and
the XLink-namespaced attribute is ignored, regardless of source order.

Two code paths were non-compliant:

- `resolve_href` (used by `<use>`) queried `xlink:href` first and only
  fell back to `href`, so `xlink:href` always won. Note that
  `roxmltree::Node::attribute("href")` matches by local name only and
  ignores the namespace, so the attributes are now filtered explicitly.
- The generic attribute-copy loop stored both `href` and `xlink:href`
  under `AId::Href`, and lookups returned whichever came first in
  document order. The unprefixed `href` now always wins.

Fixes linebender#1015

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@LaurenzV
LaurenzV force-pushed the fix/href-precedence-over-xlink branch from 2ca9e3f to c757b4b Compare August 1, 2026 08:05
@LaurenzV LaurenzV changed the title Make href take precedence over xlink:href (SVG 2) Make href take precedence over xlink:href Aug 1, 2026
@LaurenzV

LaurenzV commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator

Thanks, also checked in Chrome and they seem to do the same.

@LaurenzV
LaurenzV merged commit 376fafb into linebender:main Aug 1, 2026
5 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.

SVG2: href must take precedence over xlink:href when both are present

2 participants