-
Notifications
You must be signed in to change notification settings - Fork 291
Description
According to the SVG 2 specification, the XLink-based URL reference attributes (such as xlink:href) are deprecated and replaced by the unprefixed href attribute.
The specification explicitly defines the conflict resolution behavior when both attributes are present on the same element:
When the ‘href’ attribute is present in both the XLink namespace and without a namespace, the value of the attribute without a namespace shall be used. The attribute in the XLink namespace shall be ignored.
(Source: SVG 2 – Linking, “Deprecated XLink URL reference attributes”)
https://www.w3.org/TR/SVG2/linking.html
which is not compliant with the SVG 2 specification.
According to the spec, the unnamespaced href attribute must always take precedence when both are present, and xlink:href must be ignored.
This affects elements such as <textPath>, <use>, <image>, <a>, and other elements that accept URL reference attributes.
Demo
<svg width="200" height="200" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
<rect id="red" x="0" y="0" width="100" height="100" fill="red"/>
<rect id="green" x="0" y="0" width="100" height="100" fill="green"/>
</defs>
<!-- According to SVG 2, href MUST win, so this should be GREEN -->
<use
href="#green" xlink:href="#red"
x="20" y="20" />
</svg>resvg 0.46.0
Chrome 143/Firefox 149