ChildNode.h 589 B

1234567891011121314151617181920212223242526272829303132
  1. /*
  2. * Copyright (c) 2021, Luke Wilde <lukew@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. namespace Web::DOM {
  8. // https://dom.spec.whatwg.org/#childnode
  9. template<typename NodeType>
  10. class ChildNode {
  11. public:
  12. // https://dom.spec.whatwg.org/#dom-childnode-remove
  13. void remove_binding()
  14. {
  15. auto* node = static_cast<NodeType*>(this);
  16. // 1. If this’s parent is null, then return.
  17. if (!node->parent())
  18. return;
  19. // 2. Remove this.
  20. node->remove();
  21. }
  22. protected:
  23. ChildNode() = default;
  24. };
  25. }