Kaynağa Gözat

LibWeb: Don't crash when querying the CDataSection.assignedSlot property

Tim Ledbetter 1 yıl önce
ebeveyn
işleme
521a1be97f

+ 1 - 0
Tests/LibWeb/Text/expected/DOM/CDATASection-assignedSlot.txt

@@ -0,0 +1 @@
+PASS (didn't crash)

+ 9 - 0
Tests/LibWeb/Text/input/DOM/CDATASection-assignedSlot.html

@@ -0,0 +1,9 @@
+<script src="../include.js"></script>
+<script>
+    test(() => {
+        const xmlDocument = new DOMParser().parseFromString(`<xml></xml>`, "application/xml");
+        const cdata = xmlDocument.createCDATASection("Test CDATA");
+        const assignedSlot = cdata.assignedSlot;
+        println("PASS (didn't crash)")
+    });
+</script>

+ 1 - 1
Userland/Libraries/LibWeb/DOM/Node.h

@@ -66,7 +66,7 @@ public:
     bool is_character_data() const { return type() == NodeType::TEXT_NODE || type() == NodeType::COMMENT_NODE; }
     bool is_document_fragment() const { return type() == NodeType::DOCUMENT_FRAGMENT_NODE; }
     bool is_parent_node() const { return is_element() || is_document() || is_document_fragment(); }
-    bool is_slottable() const { return is_element() || is_text(); }
+    bool is_slottable() const { return is_element() || is_text() || is_cdata_section(); }
     bool is_attribute() const { return type() == NodeType::ATTRIBUTE_NODE; }
     bool is_cdata_section() const { return type() == NodeType::CDATA_SECTION_NODE; }
     virtual bool is_shadow_root() const { return false; }