mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 09:17:35 +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.
|
// 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);
|
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.
|
// 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) {
|
if (!attribute) {
|
||||||
auto new_attribute = TRY(Attr::create(document(), insert_as_lowercase ? name.to_lowercase() : name, value));
|
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.
|
// 5. Change attribute to value.
|
||||||
else {
|
else {
|
||||||
|
old_value = attribute->value();
|
||||||
attribute->set_value(value);
|
attribute->set_value(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
parse_attribute(attribute->local_name(), value);
|
parse_attribute(attribute->local_name(), value);
|
||||||
|
|
||||||
invalidate_style_after_attribute_change(name);
|
if (value != old_value) {
|
||||||
|
invalidate_style_after_attribute_change(name);
|
||||||
|
}
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue