Skip to content

Make href take precedence over xlink:href (SVG 2)#1080

Open
StefanoD wants to merge 1 commit into
linebender:mainfrom
StefanoD:fix/href-precedence-over-xlink
Open

Make href take precedence over xlink:href (SVG 2)#1080
StefanoD wants to merge 1 commit into
linebender:mainfrom
StefanoD:fix/href-precedence-over-xlink

Conversation

@StefanoD

Copy link
Copy Markdown

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.

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>
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

1 participant