From 9662eec3886314748d09f0205ce42d924aa487f0 Mon Sep 17 00:00:00 2001 From: Luke Wilde Date: Fri, 30 Sep 2022 19:40:19 +0100 Subject: [PATCH] LibWeb: Apply :enabled pseudo class to only certain elements I thought the spec listing out the elements again was an oversight, but it isn't, as simply inverting "is_actually_disabled" makes :enabled apply to every element. --- Userland/Libraries/LibWeb/CSS/SelectorEngine.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibWeb/CSS/SelectorEngine.cpp b/Userland/Libraries/LibWeb/CSS/SelectorEngine.cpp index 1752676817..b782a2c384 100644 --- a/Userland/Libraries/LibWeb/CSS/SelectorEngine.cpp +++ b/Userland/Libraries/LibWeb/CSS/SelectorEngine.cpp @@ -13,8 +13,14 @@ #include #include #include +#include +#include #include #include +#include +#include +#include +#include namespace Web::SelectorEngine { @@ -228,7 +234,8 @@ static inline bool matches_pseudo_class(CSS::Selector::SimpleSelector::PseudoCla case CSS::Selector::SimpleSelector::PseudoClass::Type::Enabled: // https://html.spec.whatwg.org/multipage/semantics-other.html#selector-enabled // The :enabled pseudo-class must match any button, input, select, textarea, optgroup, option, fieldset element, or form-associated custom element that is not actually disabled. - return !element.is_actually_disabled(); + return (is(element) || is(element) || is(element) || is(element) || is(element) || is(element) || is(element)) + && !element.is_actually_disabled(); case CSS::Selector::SimpleSelector::PseudoClass::Type::Checked: return matches_checked_pseudo_class(element); case CSS::Selector::SimpleSelector::PseudoClass::Type::Is: