mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 15:17:36 +00:00
LibWeb: Implement ChildNode.remove
This commit is contained in:
parent
2202428ca4
commit
7bdf0be667
7 changed files with 49 additions and 1 deletions
32
Userland/Libraries/LibWeb/DOM/ChildNode.h
Normal file
32
Userland/Libraries/LibWeb/DOM/ChildNode.h
Normal file
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Luke Wilde <lukew@serenityos.org>
|
||||
*
|
||||
* 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;
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue