mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-27 03:10:01 +00:00
LibWeb: Update DOMImplementation.createDocumentType()
name validation
This now follows the latest specification steps.
This commit is contained in:
parent
f98312d022
commit
16dbb44de2
Notes:
github-actions[bot]
2025-06-19 11:57:08 +00:00
Author: https://github.com/tcl3
Commit: 16dbb44de2
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5141
Reviewed-by: https://github.com/gmta ✅
Reviewed-by: https://github.com/trflynn89 ✅
6 changed files with 228 additions and 6 deletions
|
@ -137,14 +137,16 @@ GC::Ref<Document> DOMImplementation::create_html_document(Optional<String> const
|
|||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-domimplementation-createdocumenttype
|
||||
WebIDL::ExceptionOr<GC::Ref<DocumentType>> DOMImplementation::create_document_type(String const& qualified_name, String const& public_id, String const& system_id)
|
||||
WebIDL::ExceptionOr<GC::Ref<DocumentType>> DOMImplementation::create_document_type(String const& name, String const& public_id, String const& system_id)
|
||||
{
|
||||
// 1. Validate qualifiedName.
|
||||
TRY(Document::validate_qualified_name(realm(), qualified_name));
|
||||
|
||||
// 2. Return a new doctype, with qualifiedName as its name, publicId as its public ID, and systemId as its system ID, and with its node document set to the associated document of this.
|
||||
// 1. If name is not a valid doctype name, then throw an "InvalidCharacterError" DOMException.
|
||||
if (!is_valid_doctype_name(name))
|
||||
return WebIDL::InvalidCharacterError::create(realm(), "Invalid doctype name"_string);
|
||||
|
||||
// 2. Return a new doctype, with name as its name, publicId as its public ID, and systemId as its system ID, and with its node document set to the associated document of this.
|
||||
auto document_type = DocumentType::create(document());
|
||||
document_type->set_name(qualified_name);
|
||||
document_type->set_name(name);
|
||||
document_type->set_public_id(public_id);
|
||||
document_type->set_system_id(system_id);
|
||||
return document_type;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue