mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 02:57:42 +00:00
LibWeb: Make getElementsByClassName() case-insensitive in quirks mode
From https://dom.spec.whatwg.org/#concept-getelementsbyclassname: The comparisons for the classes must be done in an ASCII case- insensitive manner if root’s node document’s mode is "quirks", and in an identical to manner otherwise.
This commit is contained in:
parent
5a9094a70a
commit
2a38f008bf
3 changed files with 8 additions and 4 deletions
|
@ -103,9 +103,13 @@ void Element::remove_attribute(const FlyString& name)
|
|||
m_attributes.remove_first_matching([&](auto& attribute) { return attribute.name() == name; });
|
||||
}
|
||||
|
||||
bool Element::has_class(const FlyString& class_name) const
|
||||
bool Element::has_class(const FlyString& class_name, CaseSensitivity case_sensitivity) const
|
||||
{
|
||||
return any_of(m_classes.begin(), m_classes.end(), [&](auto& it) { return it == class_name; });
|
||||
return any_of(m_classes.begin(), m_classes.end(), [&](auto& it) {
|
||||
return case_sensitivity == CaseSensitivity::CaseSensitive
|
||||
? it == class_name
|
||||
: it.to_lowercase() == class_name.to_lowercase();
|
||||
});
|
||||
}
|
||||
|
||||
RefPtr<Layout::Node> Element::create_layout_node()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue