瀏覽代碼

LibWeb: Use Document::m_type to check for XML documents

...instead of doing a string compare on the DOCTYPE node.
Andreas Kling 3 年之前
父節點
當前提交
c46a8194b4
共有 1 個文件被更改,包括 3 次插入3 次删除
  1. 3 3
      Userland/Libraries/LibWeb/DOM/Document.cpp

+ 3 - 3
Userland/Libraries/LibWeb/DOM/Document.cpp

@@ -377,7 +377,7 @@ ExceptionOr<void> Document::writeln(Vector<String> const& strings)
 ExceptionOr<void> 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<void> Document::run_the_document_write_steps(String input)
 ExceptionOr<Document*> 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*> Document::open(String const&, String const&)
 ExceptionOr<void> 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.