LibWeb: Update Element class list is when class attribute is removed

This commit is contained in:
Tim Ledbetter 2024-07-23 13:06:20 +01:00 committed by Andreas Kling
parent 6e77fff698
commit 21e21abeed
Notes: github-actions[bot] 2024-07-25 04:44:34 +00:00
3 changed files with 18 additions and 2 deletions

View file

@ -0,0 +1,3 @@
element.classList initial value: ""
element.classList after setting classList to "a": "a"
element.classList after setting className to "": ""

View file

@ -0,0 +1,13 @@
<!DOCTYPE html>
<script src="../include.js"></script>
<script>
test(() => {
const element = document.createElement("div");
println(`element.classList initial value: "${element.classList.toString()}"`);
element.classList = "a";
println(`element.classList after setting classList to "a": "${element.classList.toString()}"`);
element.className = "";
println(`element.classList after setting className to "": "${element.classList.toString()}"`);
});
</script>
</html>

View file

@ -480,9 +480,9 @@ void Element::attribute_changed(FlyString const& name, Optional<String> const&,
for (auto& new_class : new_classes) {
m_classes.unchecked_append(FlyString::from_utf8(new_class).release_value_but_fixme_should_propagate_errors());
}
if (m_class_list)
m_class_list->associated_attribute_changed(value_or_empty);
}
if (m_class_list)
m_class_list->associated_attribute_changed(value_or_empty);
} else if (name == HTML::AttributeNames::style) {
if (!value.has_value()) {
if (m_inline_style) {