diff --git a/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp b/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp index 043e2811c85..a1dcd0b860a 100644 --- a/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp +++ b/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp @@ -473,6 +473,13 @@ void generate_implementation(const IDL::Interface& interface) out() << " auto " << snake_name(parameter.name) << " = interpreter.argument(" << argument_index << ").to_string(interpreter);"; out() << " if (interpreter.exception())"; out() << " return {};"; + } else if (parameter.type.name == "Node") { + out() << " auto " << snake_name(parameter.name) << "_object = interpreter.argument(" << argument_index << ").to_object(interpreter, global_object);"; + out() << " if (interpreter.exception())"; + out() << " return {};"; + out() << " if (!" << snake_name(parameter.name) << "_object->is_web_wrapper() || !static_cast(" << snake_name(parameter.name) << "_object)->is_node_wrapper())"; + out() << " return interpreter.throw_exception(JS::ErrorType::NotA, \"" << parameter.type.name << "\");"; + out() << " auto& " << snake_name(parameter.name) << " = static_cast<" << wrapper_class << "*>(" << snake_name(parameter.name) << "_object)->impl();"; } ++argument_index; } diff --git a/Libraries/LibWeb/DOM/Node.cpp b/Libraries/LibWeb/DOM/Node.cpp index 835cd68d65d..0abb77b7508 100644 --- a/Libraries/LibWeb/DOM/Node.cpp +++ b/Libraries/LibWeb/DOM/Node.cpp @@ -193,4 +193,10 @@ const Element* Node::parent_element() const return to(parent()); } +RefPtr Node::append_child(NonnullRefPtr node, bool notify) +{ + TreeNode::append_child(node, notify); + return node; +} + } diff --git a/Libraries/LibWeb/DOM/Node.h b/Libraries/LibWeb/DOM/Node.h index b0065f39b63..30504abcaf0 100644 --- a/Libraries/LibWeb/DOM/Node.h +++ b/Libraries/LibWeb/DOM/Node.h @@ -82,6 +82,8 @@ public: bool is_document_fragment() const { return type() == NodeType::DOCUMENT_FRAGMENT_NODE; } bool is_parent_node() const { return is_element() || is_document() || is_document_fragment(); } + RefPtr append_child(NonnullRefPtr, bool notify = true); + virtual RefPtr create_layout_node(const StyleProperties* parent_style) const; virtual FlyString node_name() const = 0; diff --git a/Libraries/LibWeb/DOM/Node.idl b/Libraries/LibWeb/DOM/Node.idl index 2fca1a6d8ef..3bb148197da 100644 --- a/Libraries/LibWeb/DOM/Node.idl +++ b/Libraries/LibWeb/DOM/Node.idl @@ -8,5 +8,6 @@ interface Node : EventTarget { readonly attribute Node? parentNode; readonly attribute Element? parentElement; + Node appendChild(Node node); }