瀏覽代碼

LibWeb: Do not const qualify clone_element_tree_as_our_shadow_tree

We are mutating the shadow root of the element.
Shannon Booth 1 年之前
父節點
當前提交
e11a7b668f
共有 2 個文件被更改,包括 4 次插入4 次删除
  1. 3 3
      Userland/Libraries/LibWeb/SVG/SVGUseElement.cpp
  2. 1 1
      Userland/Libraries/LibWeb/SVG/SVGUseElement.h

+ 3 - 3
Userland/Libraries/LibWeb/SVG/SVGUseElement.cpp

@@ -131,14 +131,14 @@ JS::GCPtr<DOM::Element> SVGUseElement::referenced_element()
 }
 
 // https://svgwg.org/svg2-draft/struct.html#UseShadowTree
-void SVGUseElement::clone_element_tree_as_our_shadow_tree(Element* to_clone) const
+void SVGUseElement::clone_element_tree_as_our_shadow_tree(Element* to_clone)
 {
-    const_cast<DOM::ShadowRoot&>(*shadow_root()).remove_all_children();
+    shadow_root()->remove_all_children();
 
     if (to_clone && is_valid_reference_element(*to_clone)) {
         // The ‘use’ element references another element, a copy of which is rendered in place of the ‘use’ in the document.
         auto cloned_reference_node = MUST(to_clone->clone_node(nullptr, true));
-        const_cast<DOM::ShadowRoot&>(*shadow_root()).append_child(cloned_reference_node).release_value_but_fixme_should_propagate_errors();
+        shadow_root()->append_child(cloned_reference_node).release_value_but_fixme_should_propagate_errors();
     }
 }
 

+ 1 - 1
Userland/Libraries/LibWeb/SVG/SVGUseElement.h

@@ -57,7 +57,7 @@ private:
 
     JS::GCPtr<DOM::Element> referenced_element();
 
-    void clone_element_tree_as_our_shadow_tree(Element* to_clone) const;
+    void clone_element_tree_as_our_shadow_tree(Element* to_clone);
     bool is_valid_reference_element(Element const& reference_element) const;
 
     Optional<float> m_x;