From 96e074b38f4cebf0a2f44292dde2a77112b304a1 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 21 Jan 2025 01:06:38 +0100 Subject: [PATCH] LibWeb: Make SVGSVGElement.getElementById() return Element? (nullable) This is wrong in the spec, and there's already a bug open. --- Libraries/LibWeb/SVG/SVGSVGElement.idl | 3 ++- Tests/LibWeb/Text/expected/SVG/svg-svg-getElementById.txt | 1 + Tests/LibWeb/Text/input/SVG/svg-svg-getElementById.html | 8 ++++++++ 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 Tests/LibWeb/Text/expected/SVG/svg-svg-getElementById.txt create mode 100644 Tests/LibWeb/Text/input/SVG/svg-svg-getElementById.html diff --git a/Libraries/LibWeb/SVG/SVGSVGElement.idl b/Libraries/LibWeb/SVG/SVGSVGElement.idl index d7c368cbee3..b59c24e73ca 100644 --- a/Libraries/LibWeb/SVG/SVGSVGElement.idl +++ b/Libraries/LibWeb/SVG/SVGSVGElement.idl @@ -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. diff --git a/Tests/LibWeb/Text/expected/SVG/svg-svg-getElementById.txt b/Tests/LibWeb/Text/expected/SVG/svg-svg-getElementById.txt new file mode 100644 index 00000000000..b2c18efad46 --- /dev/null +++ b/Tests/LibWeb/Text/expected/SVG/svg-svg-getElementById.txt @@ -0,0 +1 @@ +PASS: true diff --git a/Tests/LibWeb/Text/input/SVG/svg-svg-getElementById.html b/Tests/LibWeb/Text/input/SVG/svg-svg-getElementById.html new file mode 100644 index 00000000000..0a072ce46f1 --- /dev/null +++ b/Tests/LibWeb/Text/input/SVG/svg-svg-getElementById.html @@ -0,0 +1,8 @@ + + +