LibWeb: Support :placeholder-shown pseudo-class for textarea elements

Previously only input elements were matched. Add placeholder_value()
to HTMLTextAreaElement mirroring the HTMLInputElement API and update
both selector matching code paths to handle textarea.
This commit is contained in:
Praise-Garfield
2026-02-11 12:49:25 +00:00
committed by Jelle Raaijmakers
parent 933eee8284
commit ebd312689e
Notes: github-actions[bot] 2026-02-11 15:12:26 +00:00
6 changed files with 72 additions and 12 deletions

View File

@@ -477,6 +477,16 @@ bool HTMLTextAreaElement::is_mutable() const
return enabled() && !has_attribute(AttributeNames::readonly);
}
// https://html.spec.whatwg.org/multipage/form-elements.html#attr-textarea-placeholder
Optional<String> HTMLTextAreaElement::placeholder_value() const
{
if (!m_text_node || !m_text_node->data().is_empty())
return {};
if (!has_attribute(HTML::AttributeNames::placeholder))
return {};
return get_attribute_value(HTML::AttributeNames::placeholder);
}
GC::Ptr<Layout::Node> HTMLTextAreaElement::create_layout_node(GC::Ref<CSS::ComputedProperties> style)
{
return heap().allocate<Layout::TextAreaBox>(document(), *this, style);