ladybird/Userland/Libraries/LibWeb/DOM/ChildNode.h

33 lines
594 B
C
Raw Normal View History

2021-09-29 16:25:48 +01:00
/*
* Copyright (c) 2021-2022, Luke Wilde <lukew@serenityos.org>
2021-09-29 16:25:48 +01:00
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
namespace Web::DOM {
// https://dom.spec.whatwg.org/#childnode
template<typename NodeType>
class ChildNode {
public:
// https://dom.spec.whatwg.org/#dom-childnode-remove
void remove_binding()
{
auto* node = static_cast<NodeType*>(this);
// 1. If thiss parent is null, then return.
if (!node->parent())
return;
// 2. Remove this.
node->remove();
}
protected:
ChildNode() = default;
};
}