Skip to content

Commit a545935

Browse files
shannonboothawesomekling
authored andcommitted
LibWeb: Create XML Documents in DOMParser.parseFromString
1 parent cd156ba commit a545935

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
XMLDocument
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<script src="../include.js"></script>
2+
<script>
3+
test(() => {
4+
const parser = new DOMParser();
5+
const xmlDoc = parser.parseFromString('<svg></svg>', "text/xml");
6+
println(xmlDoc.constructor.name);
7+
});
8+
</script>

Userland/Libraries/LibWeb/HTML/DOMParser.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include <LibWeb/Bindings/DOMParserPrototype.h>
88
#include <LibWeb/Bindings/MainThreadVM.h>
9+
#include <LibWeb/DOM/XMLDocument.h>
910
#include <LibWeb/HTML/DOMParser.h>
1011
#include <LibWeb/HTML/HTMLDocument.h>
1112
#include <LibWeb/HTML/Parser/HTMLParser.h>
@@ -59,7 +60,7 @@ JS::NonnullGCPtr<DOM::Document> DOMParser::parse_from_string(StringView string,
5960
parser->run("about:blank"sv);
6061
} else {
6162
// -> Otherwise
62-
document = DOM::Document::create(realm(), verify_cast<HTML::Window>(relevant_global_object(*this)).associated_document().url());
63+
document = DOM::XMLDocument::create(realm(), verify_cast<HTML::Window>(relevant_global_object(*this)).associated_document().url());
6364
document->set_content_type(Bindings::idl_enum_to_string(type));
6465

6566
// 1. Create an XML parser parse, associated with document, and with XML scripting support disabled.

0 commit comments

Comments
 (0)