From c46a8194b480a6a33631c376c29deafffadcecba Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 5 Aug 2022 01:05:35 +0200 Subject: [PATCH] LibWeb: Use Document::m_type to check for XML documents ...instead of doing a string compare on the DOCTYPE node. --- Userland/Libraries/LibWeb/DOM/Document.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp index 454a3945e2..7afdbb91c9 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.cpp +++ b/Userland/Libraries/LibWeb/DOM/Document.cpp @@ -377,7 +377,7 @@ ExceptionOr Document::writeln(Vector const& strings) ExceptionOr Document::run_the_document_write_steps(String input) { // 1. If document is an XML document, then throw an "InvalidStateError" DOMException. - if (doctype() && doctype()->name() == "xml") + if (m_type == Type::XML) return DOM::InvalidStateError::create("write() called on XML document."); // 2. If document's throw-on-dynamic-markup-insertion counter is greater than 0, then throw an "InvalidStateError" DOMException. @@ -412,7 +412,7 @@ ExceptionOr Document::run_the_document_write_steps(String input) ExceptionOr Document::open(String const&, String const&) { // 1. If document is an XML document, then throw an "InvalidStateError" DOMException exception. - if (doctype() && doctype()->name() == "xml") + if (m_type == Type::XML) return DOM::InvalidStateError::create("open() called on XML document."); // 2. If document's throw-on-dynamic-markup-insertion counter is greater than 0, then throw an "InvalidStateError" DOMException. @@ -482,7 +482,7 @@ ExceptionOr Document::open(String const&, String const&) ExceptionOr Document::close() { // 1. If document is an XML document, then throw an "InvalidStateError" DOMException exception. - if (doctype() && doctype()->name() == "xml") + if (m_type == Type::XML) return DOM::InvalidStateError::create("close() called on XML document."); // 2. If document's throw-on-dynamic-markup-insertion counter is greater than 0, then throw an "InvalidStateError" DOMException.