mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 09:00:22 +00:00
LibWeb: Make DOMImplementation.createHTMLDocument() create HTMLDocument
Prior to this change, this API would actually create an XML Document(!)
This commit is contained in:
parent
b9bacb3ff4
commit
99ca2ccf08
Notes:
sideshowbarker
2024-07-17 08:25:15 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/99ca2ccf08 Pull-request: https://github.com/SerenityOS/serenity/pull/23549
5 changed files with 28 additions and 2 deletions
|
@ -0,0 +1,4 @@
|
|||
[object HTMLDocument]
|
||||
true
|
||||
[object HTMLDocument]
|
||||
true
|
|
@ -0,0 +1,12 @@
|
|||
<body>
|
||||
<script src="../include.js"></script>
|
||||
<script>
|
||||
test(() => {
|
||||
println(document);
|
||||
println(document instanceof HTMLDocument);
|
||||
let newDocument = document.implementation.createHTMLDocument();
|
||||
println(newDocument);
|
||||
println(newDocument instanceof HTMLDocument);
|
||||
});
|
||||
</script>
|
||||
</body>
|
|
@ -12,6 +12,7 @@
|
|||
#include <LibWeb/DOM/ElementFactory.h>
|
||||
#include <LibWeb/DOM/Text.h>
|
||||
#include <LibWeb/DOM/XMLDocument.h>
|
||||
#include <LibWeb/HTML/HTMLDocument.h>
|
||||
#include <LibWeb/HTML/Origin.h>
|
||||
#include <LibWeb/Namespace.h>
|
||||
|
||||
|
@ -91,10 +92,11 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Document>> DOMImplementation::create_docume
|
|||
JS::NonnullGCPtr<Document> DOMImplementation::create_html_document(Optional<String> const& title) const
|
||||
{
|
||||
// 1. Let doc be a new document that is an HTML document.
|
||||
auto html_document = Document::create(realm());
|
||||
auto html_document = HTML::HTMLDocument::create(realm());
|
||||
|
||||
// 2. Set doc’s content type to "text/html".
|
||||
html_document->set_content_type("text/html"_string);
|
||||
html_document->set_document_type(DOM::Document::Type::HTML);
|
||||
|
||||
html_document->set_ready_for_post_load_tasks(true);
|
||||
|
||||
|
|
|
@ -27,4 +27,10 @@ JS::NonnullGCPtr<HTMLDocument> HTMLDocument::create(JS::Realm& realm, URL const&
|
|||
return realm.heap().allocate<HTMLDocument>(realm, realm, url);
|
||||
}
|
||||
|
||||
void HTMLDocument::initialize(JS::Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLDocumentPrototype>(realm, "HTMLDocument"_fly_string));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace Web::HTML {
|
|||
// https://github.com/whatwg/html/issues/4792
|
||||
// https://github.com/whatwg/dom/issues/221
|
||||
class HTMLDocument final : public DOM::Document {
|
||||
JS_CELL(HTMLDocument, DOM::Document);
|
||||
WEB_PLATFORM_OBJECT(HTMLDocument, DOM::Document);
|
||||
JS_DECLARE_ALLOCATOR(HTMLDocument);
|
||||
|
||||
public:
|
||||
|
@ -25,6 +25,8 @@ public:
|
|||
WebIDL::ExceptionOr<JS::NonnullGCPtr<HTMLDocument>> construct_impl(JS::Realm&);
|
||||
|
||||
private:
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
|
||||
HTMLDocument(JS::Realm&, URL const&);
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue