LibWeb: Port attribute change steps from DeprecatedFlyString

This commit is contained in:
Shannon Booth 2023-11-07 08:07:02 +13:00 committed by Andreas Kling
parent b337b4370a
commit 7e9a40dbad
4 changed files with 6 additions and 6 deletions

View file

@ -115,7 +115,7 @@ void Attr::handle_attribute_changes(Element& element, Optional<DeprecatedString>
}
// 3. Run the attribute change steps with element, attributes local name, oldValue, newValue, and attributes 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());
}
}

View file

@ -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<DeprecatedString> const& old_value, Optional<DeprecatedString> const& value, DeprecatedFlyString const& namespace_)
void Element::run_attribute_change_steps(FlyString const& local_name, Optional<DeprecatedString> const& old_value, Optional<DeprecatedString> const& value, Optional<FlyString> const& namespace_)
{
for (auto const& attribute_change_steps : m_attribute_change_steps)
attribute_change_steps(local_name, old_value, value, namespace_);

View file

@ -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<void(FlyString const& /*local_name*/, Optional<DeprecatedString> const& /*old_value*/, Optional<DeprecatedString> const& /*value*/, DeprecatedFlyString const& /*namespace_*/)>;
using AttributeChangeSteps = Function<void(FlyString const& local_name, Optional<DeprecatedString> const& old_value, Optional<DeprecatedString> const& value, Optional<FlyString> const& namespace_)>;
void add_attribute_change_steps(AttributeChangeSteps steps);
void run_attribute_change_steps(FlyString const& local_name, Optional<DeprecatedString> const& old_value, Optional<DeprecatedString> const& value, DeprecatedFlyString const& namespace_);
void run_attribute_change_steps(FlyString const& local_name, Optional<DeprecatedString> const& old_value, Optional<DeprecatedString> const& value, Optional<FlyString> const& namespace_);
virtual void attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value);
struct [[nodiscard]] RequiredInvalidationAfterStyleChange {

View file

@ -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;