mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 23:47:45 +00:00
LibWeb: Hoist case sensitivity check out of loop in Element::has_class()
This commit is contained in:
parent
8deced39a8
commit
d9c64ee876
1 changed files with 9 additions and 5 deletions
|
@ -251,11 +251,15 @@ Vector<String> Element::get_attribute_names() const
|
|||
|
||||
bool Element::has_class(FlyString const& class_name, CaseSensitivity case_sensitivity) const
|
||||
{
|
||||
return any_of(m_classes, [&](auto& it) {
|
||||
return case_sensitivity == CaseSensitivity::CaseSensitive
|
||||
? it == class_name
|
||||
: it.equals_ignoring_case(class_name);
|
||||
});
|
||||
if (case_sensitivity == CaseSensitivity::CaseSensitive) {
|
||||
return any_of(m_classes, [&](auto& it) {
|
||||
return it == class_name;
|
||||
});
|
||||
} else {
|
||||
return any_of(m_classes, [&](auto& it) {
|
||||
return it.equals_ignoring_case(class_name);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
RefPtr<Layout::Node> Element::create_layout_node(NonnullRefPtr<CSS::StyleProperties> style)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue