LibWeb: Implement :required/:optional pseudo-classes

This commit is contained in:
Gingeh 2025-04-30 10:23:46 +10:00 committed by Sam Atkins
parent fbd1f77161
commit 7acc0f4a42
Notes: github-actions[bot] 2025-05-24 09:32:37 +00:00
13 changed files with 300 additions and 2 deletions

View file

@ -3002,6 +3002,31 @@ bool HTMLInputElement::multiple_applies() const
}
}
// https://html.spec.whatwg.org/multipage/input.html#do-not-apply
bool HTMLInputElement::required_applies() const
{
switch (type_state()) {
case TypeAttributeState::Text:
case TypeAttributeState::Search:
case TypeAttributeState::Telephone:
case TypeAttributeState::URL:
case TypeAttributeState::Email:
case TypeAttributeState::Password:
case TypeAttributeState::Date:
case TypeAttributeState::Month:
case TypeAttributeState::Week:
case TypeAttributeState::Time:
case TypeAttributeState::LocalDateAndTime:
case TypeAttributeState::Number:
case TypeAttributeState::Checkbox:
case TypeAttributeState::RadioButton:
case TypeAttributeState::FileUpload:
return true;
default:
return false;
}
}
bool HTMLInputElement::has_selectable_text() const
{
// Potential FIXME: Date, Month, Week, Time and LocalDateAndTime are rendered as a basic text input for now,