mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:07:35 +00:00
LibHTML: <a href="#foo"> should prefer any element type with id=foo
It turns out that other engines also prefer <h1 id=x> over <a name=x>. So we can just use get_element_by_id() directly without worrying about the type of element we find.
This commit is contained in:
parent
8e710b16de
commit
04b94a7695
1 changed files with 1 additions and 5 deletions
|
@ -319,11 +319,7 @@ void HtmlView::scroll_to_anchor(const StringView& name)
|
||||||
if (!document())
|
if (!document())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const HTMLAnchorElement* element = nullptr;
|
auto* element = document()->get_element_by_id(name);
|
||||||
if (auto* candidate = document()->get_element_by_id(name)) {
|
|
||||||
if (is<HTMLAnchorElement>(*candidate))
|
|
||||||
element = to<HTMLAnchorElement>(candidate);
|
|
||||||
}
|
|
||||||
if (!element) {
|
if (!element) {
|
||||||
auto candidates = document()->get_elements_by_name(name);
|
auto candidates = document()->get_elements_by_name(name);
|
||||||
for (auto* candidate : candidates) {
|
for (auto* candidate : candidates) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue