Truly independent web browser
LibWeb: Follow SVG links using xlink:href
Andreas Kling247dd3b8e17a
diff --git a/Libraries/LibWeb/DOM/Element.cpp b/Libraries/LibWeb/DOM/Element.cppindex 8bd0d69e349..59561d2b482 100644--- a/Libraries/LibWeb/DOM/Element.cpp+++ b/Libraries/LibWeb/DOM/Element.cpp@@ -640,7 +640,12 @@ void Element::follow_the_hyperlink(Optional<Utf16String> hyperlink_suffix, HTML:target_attribute_value = get_an_elements_target();// 4. Let urlRecord be the result of encoding-parsing a URL given subject's href attribute value, relative to subject's node document.- auto url_record = document().encoding_parse_url(attribute(HTML::AttributeNames::href).value_or({}));+ auto href = get_attribute_ns({}, HTML::AttributeNames::href);+ // https://svgwg.org/svg2-draft/linking.html#XLinkRefAttrs+ // NB: SVG links use xlink:href when the unnamespaced href attribute is absent.+ if (!href.has_value() && is_svg_a_element())+ href = get_attribute_ns(Namespace::XLink, HTML::AttributeNames::href);+ auto url_record = document().encoding_parse_url(href.value_or({}));// 5. If urlRecord is failure, then return.if (!url_record.has_value())diff --git a/Tests/LibWeb/Text/expected/SVG/svg-link-xlink-navigation.txt b/Tests/LibWeb/Text/expected/SVG/svg-link-xlink-navigation.txtindex 2d0922e4535..908666d34fe 100644--- a/Tests/LibWeb/Text/expected/SVG/svg-link-xlink-navigation.txt+++ b/Tests/LibWeb/Text/expected/SVG/svg-link-xlink-navigation.txt@@ -1,3 +1,3 @@-href=null:+href=null: #legacyhref="#modern": #modernhref="":