Skip to content

Commit

Permalink
LibWeb: Streamline Node::enclosing_link_element() somewhat
Browse files Browse the repository at this point in the history
No need to verify_cast repeatedly once we've confirmed the type.
  • Loading branch information
awesomekling committed Mar 2, 2022
1 parent ad9f3f7 commit 9888e29
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Userland/Libraries/LibWeb/DOM/Node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,11 @@ Node::~Node()
const HTML::HTMLAnchorElement* Node::enclosing_link_element() const
{
for (auto* node = this; node; node = node->parent()) {
if (is<HTML::HTMLAnchorElement>(*node) && verify_cast<HTML::HTMLAnchorElement>(*node).has_attribute(HTML::AttributeNames::href))
return verify_cast<HTML::HTMLAnchorElement>(node);
if (!is<HTML::HTMLAnchorElement>(*node))
continue;
auto const& anchor_element = static_cast<HTML::HTMLAnchorElement const&>(*node);
if (anchor_element.has_attribute(HTML::AttributeNames::href))
return &anchor_element;
}
return nullptr;
}
Expand Down

0 comments on commit 9888e29

Please sign in to comment.