mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 03:27:45 +00:00
LibWeb: Streamline Node::enclosing_link_element() somewhat
No need to verify_cast repeatedly once we've confirmed the type.
This commit is contained in:
parent
ad9f3f7ae6
commit
9888e29c14
1 changed files with 5 additions and 2 deletions
|
@ -81,8 +81,11 @@ Node::~Node()
|
||||||
const HTML::HTMLAnchorElement* Node::enclosing_link_element() const
|
const HTML::HTMLAnchorElement* Node::enclosing_link_element() const
|
||||||
{
|
{
|
||||||
for (auto* node = this; node; node = node->parent()) {
|
for (auto* node = this; node; node = node->parent()) {
|
||||||
if (is<HTML::HTMLAnchorElement>(*node) && verify_cast<HTML::HTMLAnchorElement>(*node).has_attribute(HTML::AttributeNames::href))
|
if (!is<HTML::HTMLAnchorElement>(*node))
|
||||||
return verify_cast<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;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue