mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:07:34 +00:00
LibWeb: Don't invalidate style when attribute set to identical value
This was a fairly common source of unnecessary style invalidations.
This commit is contained in:
parent
8142f7b196
commit
78d6e2db8c
1 changed files with 6 additions and 1 deletions
|
@ -133,6 +133,8 @@ WebIDL::ExceptionOr<void> Element::set_attribute(DeprecatedFlyString const& name
|
|||
// 3. Let attribute be the first attribute in this’s attribute list whose qualified name is qualifiedName, and null otherwise.
|
||||
auto* attribute = m_attributes->get_attribute(name);
|
||||
|
||||
DeprecatedString old_value;
|
||||
|
||||
// 4. If attribute is null, create an attribute whose local name is qualifiedName, value is value, and node document is this’s node document, then append this attribute to this, and then return.
|
||||
if (!attribute) {
|
||||
auto new_attribute = TRY(Attr::create(document(), insert_as_lowercase ? name.to_lowercase() : name, value));
|
||||
|
@ -143,12 +145,15 @@ WebIDL::ExceptionOr<void> Element::set_attribute(DeprecatedFlyString const& name
|
|||
|
||||
// 5. Change attribute to value.
|
||||
else {
|
||||
old_value = attribute->value();
|
||||
attribute->set_value(value);
|
||||
}
|
||||
|
||||
parse_attribute(attribute->local_name(), value);
|
||||
|
||||
invalidate_style_after_attribute_change(name);
|
||||
if (value != old_value) {
|
||||
invalidate_style_after_attribute_change(name);
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue