mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:47:44 +00:00
LibWeb: Make DOM::NamedNodeMap forward its ref count to DOM::Element
This allows JS to keep an element alive by retaining a reference to element.attributes
This commit is contained in:
parent
d368b08698
commit
7fc770cfac
2 changed files with 14 additions and 25 deletions
|
@ -7,6 +7,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/NonnullRefPtrVector.h>
|
||||
#include <AK/RefCountForwarder.h>
|
||||
#include <AK/RefCounted.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/StringView.h>
|
||||
|
@ -19,13 +20,13 @@ namespace Web::DOM {
|
|||
|
||||
// https://dom.spec.whatwg.org/#interface-namednodemap
|
||||
class NamedNodeMap final
|
||||
: public RefCounted<NamedNodeMap>
|
||||
: public RefCountForwarder<Element>
|
||||
, public Bindings::Wrappable {
|
||||
|
||||
public:
|
||||
using WrapperType = Bindings::NamedNodeMapWrapper;
|
||||
|
||||
static NonnullRefPtr<NamedNodeMap> create(Element const& associated_element);
|
||||
static NonnullRefPtr<NamedNodeMap> create(Element& associated_element);
|
||||
~NamedNodeMap() = default;
|
||||
|
||||
bool is_supported_property_index(u32 index) const;
|
||||
|
@ -49,9 +50,11 @@ public:
|
|||
Attribute const* remove_attribute(StringView qualified_name);
|
||||
|
||||
private:
|
||||
explicit NamedNodeMap(Element const& associated_element);
|
||||
explicit NamedNodeMap(Element& associated_element);
|
||||
|
||||
Element& associated_element() { return ref_count_target(); }
|
||||
Element const& associated_element() const { return ref_count_target(); }
|
||||
|
||||
WeakPtr<Element> m_associated_element;
|
||||
NonnullRefPtrVector<Attribute> m_attributes;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue