mirror of
https://github.com/RGBCube/serenity
synced 2025-07-10 09:47:35 +00:00
LibWeb: Make Element::set_shadow_root() disconnect any previous root
This commit is contained in:
parent
d2a99eded7
commit
b1096c2ae4
4 changed files with 7 additions and 4 deletions
|
@ -29,7 +29,7 @@ public:
|
||||||
Element* host() { return m_host; }
|
Element* host() { return m_host; }
|
||||||
Element const* host() const { return m_host; }
|
Element const* host() const { return m_host; }
|
||||||
|
|
||||||
void set_host(Element& host) { m_host = host; }
|
void set_host(Element* host) { m_host = host; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// https://dom.spec.whatwg.org/#concept-documentfragment-host
|
// https://dom.spec.whatwg.org/#concept-documentfragment-host
|
||||||
|
|
|
@ -382,8 +382,11 @@ void Element::set_shadow_root(RefPtr<ShadowRoot> shadow_root)
|
||||||
{
|
{
|
||||||
if (m_shadow_root == shadow_root)
|
if (m_shadow_root == shadow_root)
|
||||||
return;
|
return;
|
||||||
|
if (m_shadow_root)
|
||||||
|
m_shadow_root->set_host(nullptr);
|
||||||
m_shadow_root = move(shadow_root);
|
m_shadow_root = move(shadow_root);
|
||||||
m_shadow_root->set_host(*this);
|
if (m_shadow_root)
|
||||||
|
m_shadow_root->set_host(this);
|
||||||
invalidate_style();
|
invalidate_style();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ namespace Web::DOM {
|
||||||
ShadowRoot::ShadowRoot(Document& document, Element& host)
|
ShadowRoot::ShadowRoot(Document& document, Element& host)
|
||||||
: DocumentFragment(document)
|
: DocumentFragment(document)
|
||||||
{
|
{
|
||||||
set_host(host);
|
set_host(&host);
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#ref-for-get-the-parent%E2%91%A6
|
// https://dom.spec.whatwg.org/#ref-for-get-the-parent%E2%91%A6
|
||||||
|
|
|
@ -13,7 +13,7 @@ HTMLTemplateElement::HTMLTemplateElement(DOM::Document& document, DOM::Qualified
|
||||||
: HTMLElement(document, move(qualified_name))
|
: HTMLElement(document, move(qualified_name))
|
||||||
{
|
{
|
||||||
m_content = adopt_ref(*new DOM::DocumentFragment(appropriate_template_contents_owner_document(document)));
|
m_content = adopt_ref(*new DOM::DocumentFragment(appropriate_template_contents_owner_document(document)));
|
||||||
m_content->set_host(*this);
|
m_content->set_host(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
HTMLTemplateElement::~HTMLTemplateElement()
|
HTMLTemplateElement::~HTMLTemplateElement()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue