mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-12 19:19:30 +00:00
LibWeb: Ensure document.getElementsByClassName("")
returns no elements
Previously, `document.getElementsByClassName("")` would return a collection containing all elements in the given document.
This commit is contained in:
parent
faf64bfb41
commit
0fceede029
Notes:
github-actions[bot]
2024-07-23 06:59:20 +00:00
Author: https://github.com/tcl3
Commit: 0fceede029
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/773
4 changed files with 23 additions and 10 deletions
|
@ -471,14 +471,18 @@ void Element::attribute_changed(FlyString const& name, Optional<String> const&,
|
|||
|
||||
document().element_name_changed({}, *this);
|
||||
} else if (name == HTML::AttributeNames::class_) {
|
||||
auto new_classes = value_or_empty.bytes_as_string_view().split_view_if(Infra::is_ascii_whitespace);
|
||||
m_classes.clear();
|
||||
m_classes.ensure_capacity(new_classes.size());
|
||||
for (auto& new_class : new_classes) {
|
||||
m_classes.unchecked_append(FlyString::from_utf8(new_class).release_value_but_fixme_should_propagate_errors());
|
||||
if (value_or_empty.is_empty()) {
|
||||
m_classes.clear();
|
||||
} else {
|
||||
auto new_classes = value_or_empty.bytes_as_string_view().split_view_if(Infra::is_ascii_whitespace);
|
||||
m_classes.clear();
|
||||
m_classes.ensure_capacity(new_classes.size());
|
||||
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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue