Skip to content

Commit

Permalink
LibWeb: Update Element class list is when class attribute is removed
Browse files Browse the repository at this point in the history
  • Loading branch information
tcl3 committed Jul 24, 2024
1 parent 3b7534b commit f2ebd0e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Tests/LibWeb/Text/expected/DOM/Element-classList.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
element.classList initial value: ""
element.classList after setting classList to "a": "a"
element.classList after setting className to "": ""
13 changes: 13 additions & 0 deletions Tests/LibWeb/Text/input/DOM/Element-classList.html
Original file line number Diff line number Diff line change
@@ -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>
4 changes: 2 additions & 2 deletions Userland/Libraries/LibWeb/DOM/Element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit f2ebd0e

Please sign in to comment.