From 2b7775118d1d3044ecd61c892606e81ec1c5bc1f Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 20 Mar 2022 16:31:40 +0100 Subject: [PATCH] LibWeb: Clear element.style when the "style" attribute is removed We were hanging on to element inline style, even after the style attribute was removed. This made inline style sticky and impossible to remove. This patch fixes that. :^) --- Userland/Libraries/LibWeb/DOM/Element.cpp | 10 ++++++++++ Userland/Libraries/LibWeb/DOM/Element.h | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibWeb/DOM/Element.cpp b/Userland/Libraries/LibWeb/DOM/Element.cpp index b0c2f6d996..e562c1db1c 100644 --- a/Userland/Libraries/LibWeb/DOM/Element.cpp +++ b/Userland/Libraries/LibWeb/DOM/Element.cpp @@ -265,6 +265,16 @@ void Element::parse_attribute(const FlyString& name, const String& value) } } +void Element::did_remove_attribute(FlyString const& name) +{ + if (name == HTML::AttributeNames::style) { + if (m_inline_style) { + m_inline_style = nullptr; + set_needs_style_update(true); + } + } +} + enum class RequiredInvalidation { None, RepaintOnly, diff --git a/Userland/Libraries/LibWeb/DOM/Element.h b/Userland/Libraries/LibWeb/DOM/Element.h index 5747d7b9c1..f7d3047d70 100644 --- a/Userland/Libraries/LibWeb/DOM/Element.h +++ b/Userland/Libraries/LibWeb/DOM/Element.h @@ -85,7 +85,7 @@ public: virtual void apply_presentational_hints(CSS::StyleProperties&) const { } virtual void parse_attribute(const FlyString& name, const String& value); - virtual void did_remove_attribute(FlyString const&) { } + virtual void did_remove_attribute(FlyString const&); enum class NeedsRelayout { No = 0,