From 7e9a40dbad3a35bc6e4c6664314289011da63834 Mon Sep 17 00:00:00 2001 From: Shannon Booth Date: Tue, 7 Nov 2023 08:07:02 +1300 Subject: [PATCH] LibWeb: Port attribute change steps from DeprecatedFlyString --- Userland/Libraries/LibWeb/DOM/Attr.cpp | 2 +- Userland/Libraries/LibWeb/DOM/Element.cpp | 4 ++-- Userland/Libraries/LibWeb/DOM/Element.h | 4 ++-- Userland/Libraries/LibWeb/HTML/HTMLSlotElement.cpp | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Userland/Libraries/LibWeb/DOM/Attr.cpp b/Userland/Libraries/LibWeb/DOM/Attr.cpp index 8888d02532..201e25b48d 100644 --- a/Userland/Libraries/LibWeb/DOM/Attr.cpp +++ b/Userland/Libraries/LibWeb/DOM/Attr.cpp @@ -115,7 +115,7 @@ void Attr::handle_attribute_changes(Element& element, Optional } // 3. Run the attribute change steps with element, attribute’s local name, oldValue, newValue, and attribute’s namespace. - element.run_attribute_change_steps(local_name(), old_value, new_value, deprecated_namespace_uri); + element.run_attribute_change_steps(local_name(), old_value, new_value, namespace_uri()); } } diff --git a/Userland/Libraries/LibWeb/DOM/Element.cpp b/Userland/Libraries/LibWeb/DOM/Element.cpp index a75f052cc8..6ac6a30a36 100644 --- a/Userland/Libraries/LibWeb/DOM/Element.cpp +++ b/Userland/Libraries/LibWeb/DOM/Element.cpp @@ -75,7 +75,7 @@ Element::Element(Document& document, DOM::QualifiedName qualified_name) // https://dom.spec.whatwg.org/#ref-for-concept-element-attributes-change-ext① add_attribute_change_steps([this](auto const& local_name, auto const& old_value, auto const& value, auto const& namespace_) { // 1. If localName is slot and namespace is null, then: - if (local_name == HTML::AttributeNames::slot && namespace_.is_null()) { + if (local_name == HTML::AttributeNames::slot && !namespace_.has_value()) { // 1. If value is oldValue, then return. if (value == old_value) return; @@ -466,7 +466,7 @@ void Element::add_attribute_change_steps(AttributeChangeSteps steps) m_attribute_change_steps.append(move(steps)); } -void Element::run_attribute_change_steps(FlyString const& local_name, Optional const& old_value, Optional const& value, DeprecatedFlyString const& namespace_) +void Element::run_attribute_change_steps(FlyString const& local_name, Optional const& old_value, Optional const& value, Optional const& namespace_) { for (auto const& attribute_change_steps : m_attribute_change_steps) attribute_change_steps(local_name, old_value, value, namespace_); diff --git a/Userland/Libraries/LibWeb/DOM/Element.h b/Userland/Libraries/LibWeb/DOM/Element.h index 48242d0221..bcbda3d40e 100644 --- a/Userland/Libraries/LibWeb/DOM/Element.h +++ b/Userland/Libraries/LibWeb/DOM/Element.h @@ -146,10 +146,10 @@ public: virtual void apply_presentational_hints(CSS::StyleProperties&) const { } // https://dom.spec.whatwg.org/#concept-element-attributes-change-ext - using AttributeChangeSteps = Function const& /*old_value*/, Optional const& /*value*/, DeprecatedFlyString const& /*namespace_*/)>; + using AttributeChangeSteps = Function const& old_value, Optional const& value, Optional const& namespace_)>; void add_attribute_change_steps(AttributeChangeSteps steps); - void run_attribute_change_steps(FlyString const& local_name, Optional const& old_value, Optional const& value, DeprecatedFlyString const& namespace_); + void run_attribute_change_steps(FlyString const& local_name, Optional const& old_value, Optional const& value, Optional const& namespace_); virtual void attribute_changed(FlyString const& name, Optional const& value); struct [[nodiscard]] RequiredInvalidationAfterStyleChange { diff --git a/Userland/Libraries/LibWeb/HTML/HTMLSlotElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLSlotElement.cpp index 1a87d4c741..b4ef3b0988 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLSlotElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLSlotElement.cpp @@ -18,7 +18,7 @@ HTMLSlotElement::HTMLSlotElement(DOM::Document& document, DOM::QualifiedName qua // https://dom.spec.whatwg.org/#ref-for-concept-element-attributes-change-ext add_attribute_change_steps([this](auto const& local_name, auto const& old_value, auto const& value, auto const& namespace_) { // 1. If element is a slot, localName is name, and namespace is null, then: - if (local_name == AttributeNames::name && namespace_.is_null()) { + if (local_name == AttributeNames::name && !namespace_.has_value()) { // 1. If value is oldValue, then return. if (value == old_value) return;