mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 01:57:45 +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:
parent
889e6ab43d
commit
2c096486a4
2 changed files with 14 additions and 5 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue