mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:27:35 +00:00
LibWeb: Weakly store NamedNodeMap's & Attribute's associated Element
This is similar to how Gecko avoids a reference cycle, where both the NamedNodeMap and Attribute would otherwise store a strong reference to their associated Element. Gecko manually clears stored raw references when an Element is destroyed, whereas we use weak references to do so automatically. Attribute's ownerElement getter and setter are moved out of line to avoid an #include cycle between Element and Attribute.
This commit is contained in:
parent
356d5821e7
commit
b67f6daf05
4 changed files with 35 additions and 8 deletions
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <LibWeb/DOM/Attribute.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/DOM/Element.h>
|
||||
|
||||
namespace Web::DOM {
|
||||
|
||||
|
@ -22,4 +23,14 @@ Attribute::Attribute(Document& document, FlyString local_name, String value, Ele
|
|||
{
|
||||
}
|
||||
|
||||
Element const* Attribute::owner_element() const
|
||||
{
|
||||
return m_owner_element;
|
||||
}
|
||||
|
||||
void Attribute::set_owner_element(Element const* owner_element)
|
||||
{
|
||||
m_owner_element = owner_element;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue