2021-09-29 16:25:48 +01:00
|
|
|
|
/*
|
2022-01-29 20:23:48 +00: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 this’s parent is null, then return.
|
|
|
|
|
|
if (!node->parent())
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
// 2. Remove this.
|
|
|
|
|
|
node->remove();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
ChildNode() = default;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
}
|