mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-22 09:12:13 -05:00
LibWeb: Update the HTMLDetailsElement attribute change steps
No functional change here, but this contains spec steps to handle the 'name' attribute (not implemented here).
This commit is contained in:
parent
b3b9eea986
commit
1fb1d5fcb9
Notes:
github-actions[bot]
2025-01-17 09:23:33 +00:00
Author: https://github.com/trflynn89 Commit: https://github.com/LadybirdBrowser/ladybird/commit/1fb1d5fcb99 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3264
2 changed files with 31 additions and 11 deletions
|
@ -53,19 +53,39 @@ void HTMLDetailsElement::removed_from(DOM::Node*)
|
|||
set_shadow_root(nullptr);
|
||||
}
|
||||
|
||||
void HTMLDetailsElement::attribute_changed(FlyString const& name, Optional<String> const& old_value, Optional<String> const& value, Optional<FlyString> const& namespace_)
|
||||
// https://html.spec.whatwg.org/multipage/interactive-elements.html#the-details-element:concept-element-attributes-change-ext
|
||||
void HTMLDetailsElement::attribute_changed(FlyString const& local_name, Optional<String> const& old_value, Optional<String> const& value, Optional<FlyString> const& namespace_)
|
||||
{
|
||||
Base::attribute_changed(name, old_value, value, namespace_);
|
||||
Base::attribute_changed(local_name, old_value, value, namespace_);
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/interactive-elements.html#details-notification-task-steps
|
||||
if (name == HTML::AttributeNames::open) {
|
||||
// 1. If the open attribute is added, queue a details toggle event task given the details element, "closed", and "open".
|
||||
if (value.has_value()) {
|
||||
queue_a_details_toggle_event_task("closed"_string, "open"_string);
|
||||
// 1. If namespace is not null, then return.
|
||||
if (namespace_.has_value())
|
||||
return;
|
||||
|
||||
// 2. If localName is name, then ensure details exclusivity by closing the given element if needed given element.
|
||||
if (local_name == HTML::AttributeNames::name) {
|
||||
// FIXME: Implement the exclusivity steps.
|
||||
}
|
||||
|
||||
// 3. If localName is open, then:
|
||||
else if (local_name == HTML::AttributeNames::open) {
|
||||
// 1. If one of oldValue or value is null and the other is not null, run the following steps, which are known as
|
||||
// the details notification task steps, for this details element:
|
||||
{
|
||||
// 1. If oldValue is null, queue a details toggle event task given the details element, "closed", and "open".
|
||||
if (!old_value.has_value()) {
|
||||
queue_a_details_toggle_event_task("closed"_string, "open"_string);
|
||||
}
|
||||
// 2. Otherwise, queue a details toggle event task given the details element, "open", and "closed".
|
||||
else {
|
||||
queue_a_details_toggle_event_task("open"_string, "closed"_string);
|
||||
}
|
||||
}
|
||||
// 2. Otherwise, queue a details toggle event task given the details element, "open", and "closed".
|
||||
else {
|
||||
queue_a_details_toggle_event_task("open"_string, "closed"_string);
|
||||
|
||||
// 2. If oldValue is null and value is not null, then ensure details exclusivity by closing other elements if
|
||||
// needed given element.
|
||||
if (!old_value.has_value() && value.has_value()) {
|
||||
// FIXME: Implement the exclusivity steps.
|
||||
}
|
||||
|
||||
update_shadow_tree_style();
|
||||
|
|
|
@ -34,7 +34,7 @@ private:
|
|||
virtual void inserted() override;
|
||||
virtual void removed_from(DOM::Node*) override;
|
||||
virtual void children_changed() override;
|
||||
virtual void attribute_changed(FlyString const& name, Optional<String> const& old_value, Optional<String> const& value, Optional<FlyString> const& namespace_) override;
|
||||
virtual void attribute_changed(FlyString const& local_name, Optional<String> const& old_value, Optional<String> const& value, Optional<FlyString> const& namespace_) override;
|
||||
|
||||
void queue_a_details_toggle_event_task(String old_state, String new_state);
|
||||
|
||||
|
|
Loading…
Reference in a new issue