summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Wilde <lukew@serenityos.org>2022-09-30 19:40:19 +0100
committerAndreas Kling <kling@serenityos.org>2022-09-30 21:46:53 +0200
commit9662eec3886314748d09f0205ce42d924aa487f0 (patch)
tree32b761dccc371ac311e0a3b64eab51d9392681d5
parent2133b7d58ae2b971c346d28f8c092d3d2e39ec4c (diff)
downloadserenity-9662eec3886314748d09f0205ce42d924aa487f0.zip
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.
-rw-r--r--Userland/Libraries/LibWeb/CSS/SelectorEngine.cpp9
1 files changed, 8 insertions, 1 deletions
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 <LibWeb/HTML/AttributeNames.h>
#include <LibWeb/HTML/HTMLAnchorElement.h>
#include <LibWeb/HTML/HTMLAreaElement.h>
+#include <LibWeb/HTML/HTMLButtonElement.h>
+#include <LibWeb/HTML/HTMLFieldSetElement.h>
#include <LibWeb/HTML/HTMLHtmlElement.h>
#include <LibWeb/HTML/HTMLInputElement.h>
+#include <LibWeb/HTML/HTMLOptGroupElement.h>
+#include <LibWeb/HTML/HTMLOptionElement.h>
+#include <LibWeb/HTML/HTMLSelectElement.h>
+#include <LibWeb/HTML/HTMLTextAreaElement.h>
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<HTML::HTMLButtonElement>(element) || is<HTML::HTMLInputElement>(element) || is<HTML::HTMLSelectElement>(element) || is<HTML::HTMLTextAreaElement>(element) || is<HTML::HTMLOptGroupElement>(element) || is<HTML::HTMLOptionElement>(element) || is<HTML::HTMLFieldSetElement>(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: