Skip to content

Commit cf7f07b

Browse files
shannonboothawesomekling
authored andcommitted
LibWeb: Pass Element const& to is_valid_reference_element
The element can't be null - and we don't need to mutate it either.
1 parent ab70932 commit cf7f07b

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Userland/Libraries/LibWeb/SVG/SVGUseElement.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,18 +135,18 @@ void SVGUseElement::clone_element_tree_as_our_shadow_tree(Element* to_clone) con
135135
{
136136
const_cast<DOM::ShadowRoot&>(*shadow_root()).remove_all_children();
137137

138-
if (to_clone && is_valid_reference_element(to_clone)) {
138+
if (to_clone && is_valid_reference_element(*to_clone)) {
139139
// The ‘use’ element references another element, a copy of which is rendered in place of the ‘use’ in the document.
140140
auto cloned_reference_node = MUST(to_clone->clone_node(nullptr, true));
141141
const_cast<DOM::ShadowRoot&>(*shadow_root()).append_child(cloned_reference_node).release_value_but_fixme_should_propagate_errors();
142142
}
143143
}
144144

145-
bool SVGUseElement::is_valid_reference_element(Element* reference_element) const
145+
bool SVGUseElement::is_valid_reference_element(Element const& reference_element) const
146146
{
147147
// If the referenced element that results from resolving the URL is not an SVG element, then the reference is invalid and the ‘use’ element is in error.
148148
// If the referenced element is a (shadow-including) ancestor of the ‘use’ element, then this is an invalid circular reference and the ‘use’ element is in error.
149-
return reference_element->is_svg_element() && !reference_element->is_ancestor_of(*this);
149+
return reference_element.is_svg_element() && !reference_element.is_ancestor_of(*this);
150150
}
151151

152152
// https://www.w3.org/TR/SVG11/shapes.html#RectElementXAttribute

Userland/Libraries/LibWeb/SVG/SVGUseElement.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class SVGUseElement final
5858
JS::GCPtr<DOM::Element> referenced_element();
5959

6060
void clone_element_tree_as_our_shadow_tree(Element* to_clone) const;
61-
bool is_valid_reference_element(Element* reference_element) const;
61+
bool is_valid_reference_element(Element const& reference_element) const;
6262

6363
Optional<float> m_x;
6464
Optional<float> m_y;

0 commit comments

Comments
 (0)