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

LibWeb: Add support for more pseudoclasses

:disabled, :enabled and :checked are now parsed and matched. There
surely are more nuances to consider.
This commit is contained in:
Tobias Christiansen 2021-05-23 22:36:36 +02:00 committed by Ali Mohammad Pur
parent 4f4cde2379
commit b53dac6e88
4 changed files with 36 additions and 0 deletions

View file

@ -82,6 +82,24 @@ static bool matches(const CSS::Selector::SimpleSelector& component, const DOM::E
return false;
}
break;
case CSS::Selector::SimpleSelector::PseudoClass::Disabled:
if (!element.tag_name().equals_ignoring_case(HTML::TagNames::input))
return false;
if (!element.has_attribute("disabled"))
return false;
break;
case CSS::Selector::SimpleSelector::PseudoClass::Enabled:
if (!element.tag_name().equals_ignoring_case(HTML::TagNames::input))
return false;
if (element.has_attribute("disabled"))
return false;
break;
case CSS::Selector::SimpleSelector::PseudoClass::Checked:
if (!element.tag_name().equals_ignoring_case(HTML::TagNames::input))
return false;
if (!element.has_attribute("checked"))
return false;
break;
case CSS::Selector::SimpleSelector::PseudoClass::NthChild:
case CSS::Selector::SimpleSelector::PseudoClass::NthLastChild:
const auto step_size = component.nth_child_pattern.step_size;