mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-10 18:10:56 +09:00
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.
This commit is contained in:
parent
2133b7d58a
commit
9662eec388
Notes:
sideshowbarker
2024-07-17 06:32:12 +09:00
Author: https://github.com/Lubrsi
Commit: 9662eec388
Pull-request: https://github.com/SerenityOS/serenity/pull/15396
1 changed files with 8 additions and 1 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue