diff --git a/Userland/Libraries/LibWeb/DOM/DOMImplementation.cpp b/Userland/Libraries/LibWeb/DOM/DOMImplementation.cpp index 1f6aa5d69d..28a5a11dbd 100644 --- a/Userland/Libraries/LibWeb/DOM/DOMImplementation.cpp +++ b/Userland/Libraries/LibWeb/DOM/DOMImplementation.cpp @@ -20,7 +20,7 @@ DOMImplementation::DOMImplementation(Document& document) } // https://dom.spec.whatwg.org/#dom-domimplementation-createdocument -ExceptionOr> DOMImplementation::create_document(const String& namespace_, const String& qualified_name) const +ExceptionOr> DOMImplementation::create_document(const String& namespace_, const String& qualified_name, RefPtr doctype) const { // FIXME: This should specifically be an XML document. auto xml_document = Document::create(); @@ -36,7 +36,8 @@ ExceptionOr> DOMImplementation::create_document(const St element = new_element.release_value(); } - // FIXME: If doctype is non-null, append doctype to document. + if (doctype) + xml_document->append_child(doctype.release_nonnull()); if (element) xml_document->append_child(element.release_nonnull()); diff --git a/Userland/Libraries/LibWeb/DOM/DOMImplementation.h b/Userland/Libraries/LibWeb/DOM/DOMImplementation.h index 4dc03900ad..74948243be 100644 --- a/Userland/Libraries/LibWeb/DOM/DOMImplementation.h +++ b/Userland/Libraries/LibWeb/DOM/DOMImplementation.h @@ -27,8 +27,7 @@ public: return adopt_own(*new DOMImplementation(document)); } - // FIXME: Add optional DocumentType once supported by IDL - ExceptionOr> create_document(const String&, const String&) const; + ExceptionOr> create_document(String const&, String const&, RefPtr) const; NonnullRefPtr create_html_document(const String& title) const; ExceptionOr> create_document_type(String const& qualified_name, String const& public_id, String const& system_id); diff --git a/Userland/Libraries/LibWeb/DOM/DOMImplementation.idl b/Userland/Libraries/LibWeb/DOM/DOMImplementation.idl index 9ac200c546..164805eea4 100644 --- a/Userland/Libraries/LibWeb/DOM/DOMImplementation.idl +++ b/Userland/Libraries/LibWeb/DOM/DOMImplementation.idl @@ -2,9 +2,8 @@ interface DOMImplementation { - // FIXME: This is missing "optional DocumentType? doctype = null" at the end. // FIXME: This should return XMLDocument instead of Document. - [NewObject] Document createDocument(DOMString? namespace, [LegacyNullToEmptyString] DOMString qualifiedName); + [NewObject] Document createDocument(DOMString? namespace, [LegacyNullToEmptyString] DOMString qualifiedName, optional DocumentType? doctype = null); [NewObject] Document createHTMLDocument(optional DOMString title); [NewObject] DocumentType createDocumentType(DOMString qualifiedName, DOMString publicId, DOMString systemId);