mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-09 01:29:17 +00:00
LibWeb: Create XML Documents in DOMParser.parseFromString
This commit is contained in:
parent
cd156bad6b
commit
a545935997
Notes:
sideshowbarker
2024-07-17 18:13:59 +09:00
Author: https://github.com/shannonbooth
Commit: a545935997
Pull-request: https://github.com/SerenityOS/serenity/pull/22567
Reviewed-by: https://github.com/awesomekling
3 changed files with 11 additions and 1 deletions
|
@ -0,0 +1 @@
|
||||||
|
XMLDocument
|
8
Tests/LibWeb/Text/input/DOM/DOMParser-xml-document.html
Normal file
8
Tests/LibWeb/Text/input/DOM/DOMParser-xml-document.html
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
<script src="../include.js"></script>
|
||||||
|
<script>
|
||||||
|
test(() => {
|
||||||
|
const parser = new DOMParser();
|
||||||
|
const xmlDoc = parser.parseFromString('<svg></svg>', "text/xml");
|
||||||
|
println(xmlDoc.constructor.name);
|
||||||
|
});
|
||||||
|
</script>
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include <LibWeb/Bindings/DOMParserPrototype.h>
|
#include <LibWeb/Bindings/DOMParserPrototype.h>
|
||||||
#include <LibWeb/Bindings/MainThreadVM.h>
|
#include <LibWeb/Bindings/MainThreadVM.h>
|
||||||
|
#include <LibWeb/DOM/XMLDocument.h>
|
||||||
#include <LibWeb/HTML/DOMParser.h>
|
#include <LibWeb/HTML/DOMParser.h>
|
||||||
#include <LibWeb/HTML/HTMLDocument.h>
|
#include <LibWeb/HTML/HTMLDocument.h>
|
||||||
#include <LibWeb/HTML/Parser/HTMLParser.h>
|
#include <LibWeb/HTML/Parser/HTMLParser.h>
|
||||||
|
@ -59,7 +60,7 @@ JS::NonnullGCPtr<DOM::Document> DOMParser::parse_from_string(StringView string,
|
||||||
parser->run("about:blank"sv);
|
parser->run("about:blank"sv);
|
||||||
} else {
|
} else {
|
||||||
// -> Otherwise
|
// -> Otherwise
|
||||||
document = DOM::Document::create(realm(), verify_cast<HTML::Window>(relevant_global_object(*this)).associated_document().url());
|
document = DOM::XMLDocument::create(realm(), verify_cast<HTML::Window>(relevant_global_object(*this)).associated_document().url());
|
||||||
document->set_content_type(Bindings::idl_enum_to_string(type));
|
document->set_content_type(Bindings::idl_enum_to_string(type));
|
||||||
|
|
||||||
// 1. Create an XML parser parse, associated with document, and with XML scripting support disabled.
|
// 1. Create an XML parser parse, associated with document, and with XML scripting support disabled.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue