Skip to content

Commit

Permalink
LibWeb: Make SVGSVGElement.getElementById() return Element? (nullable)
Browse files Browse the repository at this point in the history
This is wrong in the spec, and there's already a bug open.
  • Loading branch information
awesomekling authored and gmta committed Jan 21, 2025
1 parent 8b097b3 commit 96e074b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Libraries/LibWeb/SVG/SVGSVGElement.idl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ interface SVGSVGElement : SVGGraphicsElement {
SVGTransform createSVGTransform();
[FIXME] SVGTransform createSVGTransformFromMatrix(optional DOMMatrix2DInit matrix = {});

Element getElementById(DOMString elementId);
// NOTE: The spec says this returns `Element` but that's a bug: https://github.com/w3c/svgwg/issues/923
Element? getElementById(DOMString elementId);

// Deprecated methods that have no effect when called,
// but which are kept for compatibility reasons.
Expand Down
1 change: 1 addition & 0 deletions Tests/LibWeb/Text/expected/SVG/svg-svg-getElementById.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PASS: true
8 changes: 8 additions & 0 deletions Tests/LibWeb/Text/input/SVG/svg-svg-getElementById.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<script src="../include.js"></script>
<svg id="svgRoot"></svg>
<script>
test(() => {
const x = svgRoot.getElementById("x");
println(`PASS: ${x === null}`);
});
</script>

0 comments on commit 96e074b

Please sign in to comment.