Przeglądaj źródła

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. :^)
Andreas Kling 3 lat temu
rodzic
commit
2b7775118d

+ 10 - 0
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 {
 enum class RequiredInvalidation {
     None,
     None,
     RepaintOnly,
     RepaintOnly,

+ 1 - 1
Userland/Libraries/LibWeb/DOM/Element.h

@@ -85,7 +85,7 @@ public:
 
 
     virtual void apply_presentational_hints(CSS::StyleProperties&) const { }
     virtual void apply_presentational_hints(CSS::StyleProperties&) const { }
     virtual void parse_attribute(const FlyString& name, const String& value);
     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 {
     enum class NeedsRelayout {
         No = 0,
         No = 0,