LibWeb: Make factory method of DOM::DocumentType fallible

This commit is contained in:
Kenneth Myhra 2023-02-14 20:47:43 +01:00 committed by Linus Groh
parent 5f552ddc5c
commit c4d559bd37
Notes: sideshowbarker 2024-07-17 10:08:28 +09:00
3 changed files with 4 additions and 4 deletions

View File

@ -114,7 +114,7 @@ JS::NonnullGCPtr<Document> DOMImplementation::create_html_document(DeprecatedStr
WebIDL::ExceptionOr<JS::NonnullGCPtr<DocumentType>> DOMImplementation::create_document_type(DeprecatedString const& qualified_name, DeprecatedString const& public_id, DeprecatedString const& system_id)
{
TRY(Document::validate_qualified_name(realm(), qualified_name));
auto document_type = DocumentType::create(document());
auto document_type = TRY(DocumentType::create(document()));
document_type->set_name(qualified_name);
document_type->set_public_id(public_id);
document_type->set_system_id(system_id);

View File

@ -9,9 +9,9 @@
namespace Web::DOM {
JS::NonnullGCPtr<DocumentType> DocumentType::create(Document& document)
WebIDL::ExceptionOr<JS::NonnullGCPtr<DocumentType>> DocumentType::create(Document& document)
{
return document.heap().allocate<DocumentType>(document.realm(), document).release_allocated_value_but_fixme_should_propagate_errors();
return MUST_OR_THROW_OOM(document.heap().allocate<DocumentType>(document.realm(), document));
}
DocumentType::DocumentType(Document& document)

View File

@ -18,7 +18,7 @@ class DocumentType final
WEB_PLATFORM_OBJECT(DocumentType, Node);
public:
static JS::NonnullGCPtr<DocumentType> create(Document&);
static WebIDL::ExceptionOr<JS::NonnullGCPtr<DocumentType>> create(Document&);
virtual ~DocumentType() override = default;