mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 16:45:03 +00:00
LibWeb: Extract changing an attribute to its own method
This will be needed outside of this the method to set an existing attribute, so do not inline this implementation.
This commit is contained in:
committed by
Ali Mohammad Pur
parent
889e6ab43d
commit
2c096486a4
@@ -71,16 +71,24 @@ void Attr::set_value(DeprecatedString value)
|
||||
// 1. If attribute’s element is null, then set attribute’s value to value.
|
||||
if (!owner_element()) {
|
||||
m_value = move(value);
|
||||
return;
|
||||
}
|
||||
|
||||
// 2. Otherwise, change attribute to value.
|
||||
// https://dom.spec.whatwg.org/#concept-element-attributes-change
|
||||
// 1. Handle attribute changes for attribute with attribute’s element, attribute’s value, and value.
|
||||
handle_attribute_changes(*owner_element(), m_value, value);
|
||||
else {
|
||||
change_attribute(move(value));
|
||||
}
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#concept-element-attributes-change
|
||||
void Attr::change_attribute(DeprecatedString value)
|
||||
{
|
||||
// 1. Let oldValue be attribute’s value.
|
||||
auto old_value = move(m_value);
|
||||
|
||||
// 2. Set attribute’s value to value.
|
||||
m_value = move(value);
|
||||
|
||||
// 3. Handle attribute changes for attribute with attribute’s element, oldValue, and value.
|
||||
handle_attribute_changes(*owner_element(), old_value, m_value);
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#handle-attribute-changes
|
||||
|
||||
@@ -33,6 +33,7 @@ public:
|
||||
|
||||
DeprecatedString const& value() const { return m_value; }
|
||||
void set_value(DeprecatedString value);
|
||||
void change_attribute(DeprecatedString value);
|
||||
|
||||
Element* owner_element();
|
||||
Element const* owner_element() const;
|
||||
|
||||
Reference in New Issue
Block a user