Files
sousa-gecko/testing/web-platform/tests/svg/path/interfaces/getPathData-css-d-vs-attribute.html
T
Virali Purbey 1fc8e80116 Bug 2047780 [wpt PR 60645] - [SVG] Implement getPathData() on SVGPathElement, a=testonly
Automatic update from web-platform-tests
[SVG] Implement `getPathData()` on `SVGPathElement`

Implements the `SVGPathData` interface mixin from the SVG Paths spec
[1] on `SVGPathElement`, exposing:

`sequence<SVGPathSegment> getPathData(optional SVGPathDataSettings);`

plus the `SVGPathSegment {type, values}` and `SVGPathDataSettings
{normalize}` dictionaries.

The method reads the `d` attribute base value (ignoring SMIL/CSS) and,
for <use> shadow instances, forwards to `CorrespondingElement()`.
With `{normalize: true}`, segments are reduced to absolute M, L, C,
Z via `SVGPathNormalizer`.

Gated behind the new experimental runtime flag `SVGPathDataAPI`.
Instrumented via `SVGPathElementGetPathData` and
`SVGPathElementGetPathDataNormalized` use counters.

[1] https://svgwg.org/specs/paths/#__svg__SVGPathData__getPathData

Design: https://docs.google.com/document/d/1uCVUqYGKgsCCu7LEtEdO3Yuea-MT-I2XsU6Eoe3mlQI/edit?usp=sharing

Bug: 40441025
Change-Id: I960bf62b31800b44bd5dd71d1e04acde8bed0553
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7859157
Reviewed-by: Fredrik Söderquist <fs@opera.com>
Commit-Queue: Virali Purbey <viralipurbey@microsoft.com>
Cr-Commit-Position: refs/heads/main@{#1647018}

--

wpt-commits: 13a109f13381905050713b0d4aab3fdf62a1da06
wpt-pr: 60645
2026-06-18 14:39:46 +00:00

37 lines
1.3 KiB
HTML

<!doctype html>
<title>SVGPathElement.getPathData() returns attribute value, not CSS d value</title>
<link rel="help" href="https://svgwg.org/specs/paths/#InterfaceSVGPathData">
<link rel="author" title="Virali Purbey" href="mailto:viralipurbey@microsoft.com">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="support/getPathData-helpers.js"></script>
<style>
#path { d: path("M 100 100 L 200 200"); }
#cssOnly { d: path("M 1 1 L 2 2"); }
</style>
<svg>
<path id="path" d="M 0 0 L 10 10"/>
<path id="cssOnly"/>
</svg>
<script>
test(() => {
assert_not_equals(getComputedStyle(path).getPropertyValue("d"),
"none", "CSS 'd' property is applied");
assert_path_data_equals(path.getPathData(), [
{ type: "M", values: [0, 0] },
{ type: "L", values: [10, 10] }
]);
}, "path.getPathData() returns attribute value, not CSS d value");
test(() => {
assert_not_equals(getComputedStyle(cssOnly).getPropertyValue("d"),
"none", "CSS 'd' property is applied");
// No `d` attribute set; the CSS `d` property must not be exposed here.
assert_path_data_equals(cssOnly.getPathData(), []);
}, "path.getPathData() returns [] when only CSS d is set (no d attribute)");
</script>