1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 08:48:11 +00:00

LibWeb: Implement CSS declaration block's "updating flag"

This flag is used to prevent reparsing the style attribute after it is
automatically updated after using the CSSOM API to mutate style.
This commit is contained in:
Andreas Kling 2022-04-11 16:56:52 +02:00
parent 66618a666b
commit a8afb883c1
4 changed files with 27 additions and 2 deletions

View file

@ -125,10 +125,22 @@ DOM::ExceptionOr<String> PropertyOwningCSSStyleDeclaration::remove_property(Prop
// https://drafts.csswg.org/cssom/#update-style-attribute-for
void ElementInlineCSSStyleDeclaration::update_style_attribute()
{
// 1. Assert: declaration blocks computed flag is unset.
// NOTE: Unnecessary, only relevant for ResolvedCSSStyleDeclaration.
// 2. Let owner node be declaration blocks owner node.
// 3. If owner node is null, then return.
if (!m_element)
return;
// 4. Set declaration blocks updating flag.
m_updating = true;
// 5. Set an attribute value for owner node using "style" and the result of serializing declaration block.
m_element->set_attribute(HTML::AttributeNames::style, serialized());
// 6. Unset declaration blocks updating flag.
m_updating = false;
}
// https://drafts.csswg.org/cssom/#set-a-css-declaration