Make href take precedence over xlink:href (SVG 2)#1080
Open
StefanoD wants to merge 1 commit into
Open
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SVG 2 requires that when both the unprefixed
hrefand the deprecatedxlink:hrefare present on an element, the value ofhrefis used and the XLink-namespaced attribute is ignored, regardless of source order.Two code paths were non-compliant:
resolve_href(used by<use>) queriedxlink:hreffirst and only fell back tohref, soxlink:hrefalways won. Note thatroxmltree::Node::attribute("href")matches by local name only and ignores the namespace, so the attributes are now filtered explicitly.hrefandxlink:hrefunderAId::Href, and lookups returned whichever came first in document order. The unprefixedhrefnow 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.