RESOLVED FIXED318096
SVGSVGElement.currentScale is a no-op on non-document-root outermost <svg>
https://bugs.webkit.org/show_bug.cgi?id=318096
Summary SVGSVGElement.currentScale is a no-op on non-document-root outermost <svg>
Karl Dubost
Reported 2026-06-28 21:55:14 PDT
SVGSVGElement.currentScale only works when the <svg> is the document root. On an inline HTML-hosted <svg>, which the SVG 2 spec defines as an outermost svg element, the setter is silently discarded and the getter returns 1. Chrome and Firefox both return the assigned value. WebKit is the outlier. <svg id="s"><rect width="100" height="100" fill="green"/></svg> <script> const s = document.getElementById("s"); s.currentScale = 2; console.log(s.currentScale); // Chrome: 2, Firefox: 2, Safari: 1 </script> currentScale/currentTranslate "only have an effect on the outermost svg element of an SVG document fragment." An SVG document fragment "starts with an 'svg' element which is either the root element of the document or whose parent element is not in the SVG namespace." So an HTML-body-child <svg> and a foreignObject→div→<svg> are outermost svg elements: 1. on setting, the assigned value must be stored, 2. and on getting it must be returned (the spec only mandates return 1 / no-op for non-outermost svg elements). https://w3c.github.io/svgwg/svg2-draft/struct.html#__svg__SVGSVGElement__currentScale
Attachments
Radar WebKit Bug Importer
Comment 1 2026-06-28 21:55:20 PDT
Karl Dubost
Comment 2 2026-06-28 22:00:39 PDT
This is because of if (!isConnected() || !isOutermostSVGSVGElement() || document().documentElement() != this) return nullptr; in Source/WebCore/svg/SVGSVGElement.cpp, frameForCurrentScale() There is another but that should be addressed separately: Visual magnification of inline SVG: Chrome-only; Firefox and the existing WPT reftest svg/struct/reftests/currentScale-change-repaint.html (reference unchanged 100×100) both reject it. Need more discussions in the SVG WG.
Karl Dubost
Comment 3 2026-06-28 22:20:07 PDT
EWS
Comment 4 2026-08-06 20:12:40 PDT
Committed 318762@main (c6bd8acdac1f): <https://commits.webkit.org/318762@main> Reviewed commits have been landed. Closing PR #68077 and removing active labels.
Note You need to log in before you can comment on or make changes to this bug.