LibWeb: Allow :link and :any-link to match SVG <a> elements

This commit is contained in:
Andreas Kling 2024-11-06 18:07:28 +01:00 committed by Andreas Kling
parent 92d9907f8f
commit eeba30f988
Notes: github-actions[bot] 2024-11-06 20:43:50 +00:00
2 changed files with 4 additions and 4 deletions

View file

@ -6,8 +6,7 @@ Rerun
Found 2 tests Found 2 tests
1 Pass 2 Pass
1 Fail
Details Details
Result Test Name MessagePass :any-link & :link pseudo-class invalidation with an HTML link Result Test Name MessagePass :any-link & :link pseudo-class invalidation with an HTML link
Fail :any-link & :link pseudo-class invalidation with an SVG link Pass :any-link & :link pseudo-class invalidation with an SVG link

View file

@ -31,6 +31,7 @@
#include <LibWeb/HTML/HTMLTextAreaElement.h> #include <LibWeb/HTML/HTMLTextAreaElement.h>
#include <LibWeb/Infra/Strings.h> #include <LibWeb/Infra/Strings.h>
#include <LibWeb/Namespace.h> #include <LibWeb/Namespace.h>
#include <LibWeb/SVG/SVGAElement.h>
namespace Web::SelectorEngine { namespace Web::SelectorEngine {
@ -151,7 +152,7 @@ static inline bool matches_has_pseudo_class(CSS::Selector const& selector, Optio
static inline bool matches_link_pseudo_class(DOM::Element const& element) static inline bool matches_link_pseudo_class(DOM::Element const& element)
{ {
// All a elements that have an href attribute, and all area elements that have an href attribute, must match one of :link and :visited. // All a elements that have an href attribute, and all area elements that have an href attribute, must match one of :link and :visited.
if (!is<HTML::HTMLAnchorElement>(element) && !is<HTML::HTMLAreaElement>(element)) if (!is<HTML::HTMLAnchorElement>(element) && !is<HTML::HTMLAreaElement>(element) && !is<SVG::SVGAElement>(element))
return false; return false;
return element.has_attribute(HTML::AttributeNames::href); return element.has_attribute(HTML::AttributeNames::href);
} }