From 039e0d478a41068e8696bb28dfb223182ee81c98 Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Sat, 18 Jan 2025 20:11:17 +0100 Subject: [PATCH] LibWeb: Use invalidation sets for id attribute style invalidation --- Libraries/LibWeb/DOM/Element.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Libraries/LibWeb/DOM/Element.cpp b/Libraries/LibWeb/DOM/Element.cpp index cbc837a9886..5adcef7e31f 100644 --- a/Libraries/LibWeb/DOM/Element.cpp +++ b/Libraries/LibWeb/DOM/Element.cpp @@ -2016,6 +2016,17 @@ void Element::invalidate_style_after_attribute_change(FlyString const& attribute return; } + if (attribute_name == HTML::AttributeNames::id) { + Vector changed_properties; + if (old_value.has_value()) + changed_properties.append({ .type = CSS::InvalidationSet::Property::Type::Id, .name = old_value.value() }); + if (new_value.has_value()) + changed_properties.append({ .type = CSS::InvalidationSet::Property::Type::Id, .name = new_value.value() }); + changed_properties.append({ .type = CSS::InvalidationSet::Property::Type::Attribute, .name = HTML::AttributeNames::id }); + invalidate_style(StyleInvalidationReason::ElementAttributeChange, changed_properties); + return; + } + if (is_presentational_hint(attribute_name) || attribute_name_may_affect_selectors(*this, attribute_name)) { invalidate_style(StyleInvalidationReason::ElementAttributeChange);