mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-07 08:39:22 +00:00
LibWeb: Update m_inline_style when element style attribute is removed
Previously we would just throw it away and construct a new (empty) one when required. This doesn't work as any existing references to the old instance will contain out of date information. Now we retain and update the existing instance instead.
This commit is contained in:
parent
f53bec3a67
commit
610ad25555
Notes:
github-actions[bot]
2025-06-09 11:08:02 +00:00
Author: https://github.com/Calme1709
Commit: 610ad25555
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5035
Reviewed-by: https://github.com/AtkinsSJ ✅
Reviewed-by: https://github.com/tcl3
3 changed files with 21 additions and 14 deletions
|
@ -3637,20 +3637,13 @@ void Element::attribute_changed(FlyString const& local_name, Optional<String> co
|
|||
if (m_class_list)
|
||||
m_class_list->associated_attribute_changed(value_or_empty);
|
||||
} else if (local_name == HTML::AttributeNames::style) {
|
||||
if (!value.has_value()) {
|
||||
if (m_inline_style) {
|
||||
m_inline_style = nullptr;
|
||||
set_needs_style_update(true);
|
||||
}
|
||||
} else {
|
||||
// https://drafts.csswg.org/cssom/#ref-for-cssstyledeclaration-updating-flag
|
||||
if (m_inline_style && m_inline_style->is_updating())
|
||||
return;
|
||||
if (!m_inline_style)
|
||||
m_inline_style = CSS::CSSStyleProperties::create_element_inline_style({ *this }, {}, {});
|
||||
m_inline_style->set_declarations_from_text(*value);
|
||||
set_needs_style_update(true);
|
||||
}
|
||||
// https://drafts.csswg.org/cssom/#ref-for-cssstyledeclaration-updating-flag
|
||||
if (m_inline_style && m_inline_style->is_updating())
|
||||
return;
|
||||
if (!m_inline_style)
|
||||
m_inline_style = CSS::CSSStyleProperties::create_element_inline_style({ *this }, {}, {});
|
||||
m_inline_style->set_declarations_from_text(value.value_or(""_string));
|
||||
set_needs_style_update(true);
|
||||
} else if (local_name == HTML::AttributeNames::dir) {
|
||||
// https://html.spec.whatwg.org/multipage/dom.html#attr-dir
|
||||
if (value_or_empty.equals_ignoring_ascii_case("ltr"sv))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue