From eeba30f988a97e271858bff389b78fa8149be4a5 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 6 Nov 2024 18:07:28 +0100 Subject: [PATCH] LibWeb: Allow :link and :any-link to match SVG elements --- .../css/selectors/invalidation/link-pseudo-class-in-has.txt | 5 ++--- Userland/Libraries/LibWeb/CSS/SelectorEngine.cpp | 3 ++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/selectors/invalidation/link-pseudo-class-in-has.txt b/Tests/LibWeb/Text/expected/wpt-import/css/selectors/invalidation/link-pseudo-class-in-has.txt index da1e5a2a060..5814769ba74 100644 --- a/Tests/LibWeb/Text/expected/wpt-import/css/selectors/invalidation/link-pseudo-class-in-has.txt +++ b/Tests/LibWeb/Text/expected/wpt-import/css/selectors/invalidation/link-pseudo-class-in-has.txt @@ -6,8 +6,7 @@ Rerun Found 2 tests -1 Pass -1 Fail +2 Pass Details 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 \ No newline at end of file +Pass :any-link & :link pseudo-class invalidation with an SVG link \ No newline at end of file diff --git a/Userland/Libraries/LibWeb/CSS/SelectorEngine.cpp b/Userland/Libraries/LibWeb/CSS/SelectorEngine.cpp index e5aaf79697f..375e3b34745 100644 --- a/Userland/Libraries/LibWeb/CSS/SelectorEngine.cpp +++ b/Userland/Libraries/LibWeb/CSS/SelectorEngine.cpp @@ -31,6 +31,7 @@ #include #include #include +#include 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) { // 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(element) && !is(element)) + if (!is(element) && !is(element) && !is(element)) return false; return element.has_attribute(HTML::AttributeNames::href); }