1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 18:47:34 +00:00

LibWeb: Make :checked selector actually look at checkedness

It was incorrectly testing for presence of the "checked" attribute.
This commit is contained in:
Andreas Kling 2022-02-15 23:50:16 +01:00
parent d2ade9800f
commit eec34ae0e9

View file

@ -12,6 +12,7 @@
#include <LibWeb/DOM/Text.h>
#include <LibWeb/HTML/AttributeNames.h>
#include <LibWeb/HTML/HTMLHtmlElement.h>
#include <LibWeb/HTML/HTMLInputElement.h>
namespace Web::SelectorEngine {
@ -105,9 +106,7 @@ static inline bool matches_pseudo_class(CSS::Selector::SimpleSelector::PseudoCla
case CSS::Selector::SimpleSelector::PseudoClass::Type::Checked:
if (!element.tag_name().equals_ignoring_case(HTML::TagNames::input))
return false;
if (!element.has_attribute("checked"))
return false;
return true;
return static_cast<HTML::HTMLInputElement const&>(element).checked();
case CSS::Selector::SimpleSelector::PseudoClass::Type::Not:
for (auto& selector : pseudo_class.not_selector) {
if (matches(selector, element))