-
Notifications
You must be signed in to change notification settings - Fork 22.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add getPathSegmentAtLength method #38796
base: main
Are you sure you want to change the base?
Conversation
Preview URLs Flaws (43)Note! 1 document with no flaws that don't need to be listed. 🎉 URL:
(comment last updated: 2025-03-28 16:33:49) |
1dd0679
to
e0e6ea2
Compare
Force pushed to remove all the extraneous history. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some suggestions
|
||
### Return value | ||
|
||
A path segment object. If no valid segment exists, returns null. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to add the SVGPathSegment interface so we can link to {{domxref("SVGPathSegment")}} so the red links at https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/Releases/137 work.
A path segment object. If no valid segment exists, returns null. | |
A {{domxref("SVGPathSegment")}}. If no valid segment exists, returns `null`. |
Then we can move the rest of this return value into the interface page, like we do with all other SVG props
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough. This one is my bad - I thought the property was essentially a dictionary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@estelle we were already working with @hamishwillee on this PR and another one, fixing red underlines in the release notes. The SVGPathSegment
interface is not supposed to be mentioned in the release notes. It’s not supported in Firefox.
Yes, all new SVG data APIs are supposed to work with the SVGPathSegment
interface, but there’s a problem: it’s not implemented anywhere. I checked all SVG interfaces listed on the SVG API page: they are all supported in browsers, with a few deprecated exceptions.
Since window['SVGPathSegment'] !== undefined
returns false
, I don’t think we should document an interface that’s not implemented in any browser. Instead, I called those path data “segments” and described their structure.
I’d like to move on with the existing approach and update it in the future if needed.
```js | ||
const path = document.querySelector("path"); | ||
|
||
console.log(path.getPathSegmentAtLength(65)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
console.log(path.getPathSegmentAtLength(65)); | |
console.dir(path.getPathSegmentAtLength(65)); |
or
console.log(path.getPathSegmentAtLength(65)); | |
const pathSegment = path.getPathSegmentAtLength(65); | |
console.log(pathSegment.type); // output: "v" | |
console.log(pathSegment.value); // output: 64 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, it’s not self-evident why any of these are better than just logging. Could you please expand?
@@ -33,6 +33,8 @@ _This interface also inherits methods from its parent, {{domxref("SVGGeometryEle | |||
- : Returns the user agent's computed value for the total length of the path in user units. | |||
- {{domxref("SVGPathElement.setPathData()")}} {{experimental_inline}} | |||
- : Sets the sequence of path segments as the new path data. | |||
- {{domxref("SVGPathElement.getPathSegmentAtLength()")}} | |||
- : Returns the segment at a given distance along the path. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- : Returns the segment at a given distance along the path. | |
- : Returns the {{domxref("SVGPathSegment")}} at the given distance along the path. |
files/en-us/web/api/svgpathelement/getpathsegmentatlength/index.md
Outdated
Show resolved
Hide resolved
files/en-us/web/api/svgpathelement/getpathsegmentatlength/index.md
Outdated
Show resolved
Hide resolved
…x.md Co-authored-by: Estelle Weyl <estelle@openwebdocs.org>
…x.md Co-authored-by: Estelle Weyl <estelle@openwebdocs.org>
Description
Documents new
getPathSegmentAtLength
method shipped behind a flag in Firefox 136, enabled by default in Firefox 137.Additional details
Already in BCD and in all relevant release notes.
Related issues and pull requests