Skip to content

Commit

Permalink
LibWeb: Set the correct prototype for SVGAElement instances
Browse files Browse the repository at this point in the history
  • Loading branch information
awesomekling committed Jun 28, 2024
1 parent a84261e commit 4db05ec
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions Tests/LibWeb/Text/expected/SVG/a-element-prototype.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
true
7 changes: 7 additions & 0 deletions Tests/LibWeb/Text/input/SVG/a-element-prototype.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<script src="../include.js"></script>
<script>
test(() => {
let a = document.createElementNS("http://www.w3.org/2000/svg", "a");
println(a.__proto__ === SVGAElement.prototype);
});
</script>
7 changes: 7 additions & 0 deletions Userland/Libraries/LibWeb/SVG/SVGAElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/

#include <LibWeb/Bindings/SVGAElementPrototype.h>
#include <LibWeb/Layout/SVGGraphicsBox.h>
#include <LibWeb/SVG/SVGAElement.h>

Expand All @@ -18,6 +19,12 @@ SVGAElement::SVGAElement(DOM::Document& document, DOM::QualifiedName qualified_n

SVGAElement::~SVGAElement() = default;

void SVGAElement::initialize(JS::Realm& realm)
{
Base::initialize(realm);
WEB_SET_PROTOTYPE_FOR_INTERFACE(SVGAElement);
}

JS::GCPtr<Layout::Node> SVGAElement::create_layout_node(NonnullRefPtr<CSS::StyleProperties> style)
{
return heap().allocate_without_realm<Layout::SVGGraphicsBox>(document(), *this, move(style));
Expand Down
6 changes: 4 additions & 2 deletions Userland/Libraries/LibWeb/SVG/SVGAElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ class SVGAElement final : public SVGGraphicsElement {
public:
virtual ~SVGAElement() override;

SVGAElement(DOM::Document&, DOM::QualifiedName);

virtual JS::GCPtr<Layout::Node> create_layout_node(NonnullRefPtr<CSS::StyleProperties>) override;

private:
SVGAElement(DOM::Document&, DOM::QualifiedName);
virtual void initialize(JS::Realm&) override;
};

}

0 comments on commit 4db05ec

Please sign in to comment.