mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-03 07:07:23 +00:00
LibWeb: Implement popover property and attribute
The popover property now reflects the attribute. It cannot currently use the Reflect IDL concept because the empty string value is special cased.
This commit is contained in:
committed by
Andreas Kling
parent
197f57f5d2
commit
a9669639ce
@@ -645,6 +645,34 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<ElementInternals>> HTMLElement::attach_inte
|
||||
return { internals };
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/popover.html#dom-popover
|
||||
Optional<String> HTMLElement::popover() const
|
||||
{
|
||||
// FIXME: This should probably be `Reflect` in the IDL.
|
||||
// The popover IDL attribute must reflect the popover attribute, limited to only known values.
|
||||
auto value = get_attribute(HTML::AttributeNames::popover);
|
||||
|
||||
if (!value.has_value())
|
||||
return {};
|
||||
|
||||
if (value.value().is_empty() || value.value().equals_ignoring_ascii_case("auto"sv))
|
||||
return "auto"_string;
|
||||
|
||||
return "manual"_string;
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/popover.html#dom-popover
|
||||
WebIDL::ExceptionOr<void> HTMLElement::set_popover(Optional<String> value)
|
||||
{
|
||||
// FIXME: This should probably be `Reflect` in the IDL.
|
||||
// The popover IDL attribute must reflect the popover attribute, limited to only known values.
|
||||
if (value.has_value())
|
||||
return set_attribute(HTML::AttributeNames::popover, value.release_value());
|
||||
|
||||
remove_attribute(HTML::AttributeNames::popover);
|
||||
return {};
|
||||
}
|
||||
|
||||
void HTMLElement::did_receive_focus()
|
||||
{
|
||||
if (m_content_editable_state != ContentEditableState::True)
|
||||
|
||||
Reference in New Issue
Block a user