Skip to content

Truly independent web browser

LibWeb: Avoid style updates for empty Typed OM appends

Andreas Klingd27fde62ea89
diff --git a/Libraries/LibWeb/CSS/StylePropertyMap.cpp b/Libraries/LibWeb/CSS/StylePropertyMap.cpp
index 07700d6ce84..c03ecddebf9 100644
--- a/Libraries/LibWeb/CSS/StylePropertyMap.cpp
+++ b/Libraries/LibWeb/CSS/StylePropertyMap.cpp
@@ -315,6 +315,10 @@ WebIDL::ExceptionOr<void> StylePropertyMap::append(Utf16FlyString property_name,
return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, Utf16String::formatted("Existing value for '{}' contains var() references.", property_name) };
}
+ // NB: Appending no values must not replace the declaration or update the style attribute.
+ if (values.is_empty())
+ return {};
+
// 9. Let temp values be an empty list.
// NB: StyleValues are immutable, so we always create a new one. We add directly to it instead of using "temp values".
StyleValueVector value_list;
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/inline/attribute-changed-callback.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/inline/attribute-changed-callback.txt
index 77fa8f3e17a..f14d7e27566 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/inline/attribute-changed-callback.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/inline/attribute-changed-callback.txt
@@ -2,14 +2,13 @@ Harness status: OK
Found 11 tests
-10 Pass
-1 Fail
+11 Pass
Pass attributeStyleMap.set() triggers attributeChangedCallback
Pass attributeStyleMap.set() triggers attributeChangedCallback with correct old/new values
Pass attributeStyleMap.delete() triggers attributeChangedCallback
Pass attributeStyleMap.clear() triggers attributeChangedCallback
Pass attributeStyleMap.append() triggers attributeChangedCallback
-Fail attributeStyleMap.append() with no values does not trigger attributeChangedCallback
+Pass attributeStyleMap.append() with no values does not trigger attributeChangedCallback
Pass attributeStyleMap.set() with custom property triggers attributeChangedCallback
Pass attributeStyleMap.delete() with custom property triggers attributeChangedCallback
Pass attributeStyleMap.set() with shorthand property triggers attributeChangedCallback