You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Address review feedback on SVG Path Data API explainer
- Fix security claim: setPathData() operates on structured data, no string
parsing needed (does not go through setAttribute)
- Add arc-to-cubic normalization precision note
- Document empty path behavior: getPathData() returns [], setPathData([])
clears the path
- Document getPathSegmentAtLength edge cases: null for empty/NaN, clamp
negative to 0
- Split before/after example into separate code blocks to avoid variable
redeclaration
- Fix Chrome 48 date from 2015 to Jan 2016 (stable release date)
- Fix spec PR status wording: 'to be filed' instead of 'pending'
Copy file name to clipboardExpand all lines: SVG/SVGPathDataAPI/explainer.md
+23-4Lines changed: 23 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -47,11 +47,11 @@ The API is specified in the [SVG Paths](https://svgwg.org/specs/paths/#DOMInterf
47
47
48
48
SVG `<path>` elements define their shape through a `d` attribute string. Today in Chrome, the only way to inspect or modify individual path segments is to parse this raw string manually or include a polyfill. This can result in slower interactions, larger page loads, and degraded UX - especially on low-end devices.
49
49
50
-
Chromium removed the old `SVGPathSegList` API in **Chrome 48** (2015) because it was overly complex and poorly specified. The SVG WG specified a cleaner replacement, but it has not yet been implemented in Chrome - a gap that has persisted for over 10 years.
50
+
Chromium removed the old `SVGPathSegList` API in **Chrome 48** (Jan 2016) because it was overly complex and poorly specified. The SVG WG specified a cleaner replacement, but it has not yet been implemented in Chrome - a gap that has persisted for over 10 years.
51
51
52
52
| Engine | Old API (`SVGPathSegList`) | New API (`getPathData`/`setPathData`) |
All 20 SVG path commands (M, m, L, l, H, h, V, v, C, c, S, s, Q, q, T, t, A, a, Z, z) are supported. See the [spec](https://svgwg.org/specs/paths/#DOMInterfaces) for the full type/values mapping.
126
141
127
142
**Normalization** (`{normalize: true}`) converts all segments to absolute **M, L, C, Z** only - relative to absolute, H/V to L, Q/T to C, S to C, A to C. Consumers need only handle 4 command types.
128
143
144
+
> **Note:** Arc-to-cubic conversion (A → C) is an approximation using midpoint subdivision and is inherently lossy. The precision matches the existing `getTotalLength()`/`getPointAtLength()` code path in Blink. For most use cases the approximation error is sub-pixel.
145
+
129
146
### Before and after
130
147
131
148
```js
@@ -134,7 +151,9 @@ const d = path.getAttribute('d');
134
151
constsegments=myCustomParser(d); // or load ~4KB polyfill
@@ -186,7 +205,7 @@ The formal WebIDL is in the [Appendix](#appendix-webidl).
186
205
-**Accessibility:** No impact. Programmatic API only - no new visual content, interaction patterns, or ARIA roles. Indirectly benefits a11y by making it easier to build well-structured SVG.
187
206
-**Internationalization:** No impact. Path data uses single-character Latin commands and numbers only.
188
207
-**Privacy:** No new concerns. Returns the same data available via `getAttribute('d')` - purely a convenience API over existing capabilities. No fingerprinting surface, no network requests.
189
-
-**Security:** No new concerns. Operates entirely within the renderer, no IPC, no untrusted data. `setPathData()` goes through the existing hardened`setAttribute("d")` code path. Gated behind a feature flag.
208
+
-**Security:** No new concerns. Operates entirely within the renderer on already-structured data. No string parsing is needed (segments are pre-typed), reducing attack surface compared to`setAttribute('d')`. No IPC. Gated behind a feature flag.
0 commit comments