mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:17:44 +00:00
LibWeb: Implement document.anchors
This returns an HTMLCollection of all <a> elements in the document that have a "name" attribute.
This commit is contained in:
parent
43d16fa5b6
commit
b74bf31a53
3 changed files with 12 additions and 0 deletions
|
@ -32,6 +32,7 @@
|
|||
#include <LibWeb/Dump.h>
|
||||
#include <LibWeb/HTML/AttributeNames.h>
|
||||
#include <LibWeb/HTML/EventNames.h>
|
||||
#include <LibWeb/HTML/HTMLAnchorElement.h>
|
||||
#include <LibWeb/HTML/HTMLBodyElement.h>
|
||||
#include <LibWeb/HTML/HTMLFrameSetElement.h>
|
||||
#include <LibWeb/HTML/HTMLHeadElement.h>
|
||||
|
@ -517,6 +518,15 @@ NonnullRefPtr<HTMLCollection> Document::applets()
|
|||
return HTMLCollection::create(*this, [] { return false; });
|
||||
}
|
||||
|
||||
NonnullRefPtr<HTMLCollection> Document::anchors()
|
||||
{
|
||||
// FIXME: This should return the same HTMLCollection object every time,
|
||||
// but that would cause a reference cycle since HTMLCollection refs the root.
|
||||
return HTMLCollection::create(*this, [](Element const& element) {
|
||||
return is<HTML::HTMLAnchorElement>(element) && element.has_attribute(HTML::AttributeNames::name);
|
||||
});
|
||||
}
|
||||
|
||||
Color Document::link_color() const
|
||||
{
|
||||
if (m_link_color.has_value())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue