mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 00:25:12 +00:00
LibHTML: Implement some very simple selector matching.
We walk the entire DOM and check all selectors against all elements. Only id, class and tag name are checked right now. There's no ancestor stack or compound selectors. All in good time :^)
This commit is contained in:
@@ -50,6 +50,19 @@ void Element::set_attributes(Vector<Attribute>&& attributes)
|
||||
m_attributes = move(attributes);
|
||||
}
|
||||
|
||||
bool Element::has_class(const StringView& class_name) const
|
||||
{
|
||||
auto value = attribute("class");
|
||||
if (value.is_empty())
|
||||
return false;
|
||||
auto parts = value.split_view(' ');
|
||||
for (auto& part : parts) {
|
||||
if (part == class_name)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
RefPtr<LayoutNode> Element::create_layout_node()
|
||||
{
|
||||
if (m_tag_name == "html")
|
||||
|
||||
Reference in New Issue
Block a user