mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-30 04:39:06 +00:00
LibWeb: Get the first DOM node with a 'title' attribute for tooltip area
Rather than expecting the first parent to have a 'title' attribute, search all ancestors.
This commit is contained in:
parent
4fac577cf0
commit
c503047c71
Notes:
sideshowbarker
2024-07-18 20:57:05 +09:00
Author: https://github.com/trflynn89
Commit: c503047c71
Pull-request: https://github.com/SerenityOS/serenity/pull/6026
Reviewed-by: https://github.com/awesomekling
3 changed files with 11 additions and 1 deletions
|
@ -76,6 +76,15 @@ const HTML::HTMLElement* Node::enclosing_html_element() const
|
|||
return first_ancestor_of_type<HTML::HTMLElement>();
|
||||
}
|
||||
|
||||
const HTML::HTMLElement* Node::enclosing_html_element_with_attribute(const FlyString& attribute) const
|
||||
{
|
||||
for (auto* node = this; node; node = node->parent()) {
|
||||
if (is<HTML::HTMLElement>(*node) && downcast<HTML::HTMLElement>(*node).has_attribute(attribute))
|
||||
return downcast<HTML::HTMLElement>(node);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
String Node::text_content() const
|
||||
{
|
||||
StringBuilder builder;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue