From 04b94a769521f7f8311463991be34572c9a37cac Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 21 Oct 2019 12:12:23 +0200 Subject: [PATCH] LibHTML: should prefer any element type with id=foo It turns out that other engines also prefer

over . So we can just use get_element_by_id() directly without worrying about the type of element we find. --- Libraries/LibHTML/HtmlView.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Libraries/LibHTML/HtmlView.cpp b/Libraries/LibHTML/HtmlView.cpp index b467290cdf..a8948f8f18 100644 --- a/Libraries/LibHTML/HtmlView.cpp +++ b/Libraries/LibHTML/HtmlView.cpp @@ -319,11 +319,7 @@ void HtmlView::scroll_to_anchor(const StringView& name) if (!document()) return; - const HTMLAnchorElement* element = nullptr; - if (auto* candidate = document()->get_element_by_id(name)) { - if (is(*candidate)) - element = to(candidate); - } + auto* element = document()->get_element_by_id(name); if (!element) { auto candidates = document()->get_elements_by_name(name); for (auto* candidate : candidates) {