Skip to content
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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

pepelsbey
Copy link
Member

@pepelsbey pepelsbey commented Mar 25, 2025

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

@pepelsbey pepelsbey requested a review from hamishwillee March 25, 2025 12:25
@pepelsbey pepelsbey requested a review from a team as a code owner March 25, 2025 12:25
@pepelsbey pepelsbey requested review from sideshowbarker and removed request for a team March 25, 2025 12:25
@github-actions github-actions bot added Content:WebAPI Web API docs size/m [PR only] 51-500 LoC changed labels Mar 25, 2025
@pepelsbey pepelsbey removed the request for review from sideshowbarker March 25, 2025 12:26
Copy link
Contributor

github-actions bot commented Mar 25, 2025

Preview URLs

Flaws (43)

Note! 1 document with no flaws that don't need to be listed. 🎉

URL: /en-US/docs/Web/API/SVGPathElement
Title: SVGPathElement
Flaw count: 43

  • macros:
    • Macro produces link /en-US/docs/Web/SVG/Element/path which is a redirect
    • Macro produces link /en-US/docs/Web/SVG/Attribute/pathLength which is a redirect
    • Can't resolve /en-US/docs/Web/API/SVGPathElement/getPathSegAtLength
    • Can't resolve /en-US/docs/Web/API/SVGAnimatedPathData/pathSegList
    • Can't resolve /en-US/docs/Web/API/SVGPathElement/createSVGPathSegClosePath
    • and 38 more flaws omitted

(comment last updated: 2025-03-28 16:33:49)

@pepelsbey pepelsbey requested review from mdn-bot and a team as code owners March 26, 2025 10:57
@pepelsbey pepelsbey requested review from Josh-Cena, estelle, jpmedley and dipikabh and removed request for a team March 26, 2025 10:57
@github-actions github-actions bot added Content:CSS Cascading Style Sheets docs Content:HTML Hypertext Markup Language docs Content:WebExt WebExtensions docs Content:JS JavaScript docs Content:Accessibility Accessibility docs labels Mar 26, 2025
@github-actions github-actions bot added size/m [PR only] 51-500 LoC changed and removed Content:CSS Cascading Style Sheets docs Content:HTML Hypertext Markup Language docs Content:WebExt WebExtensions docs Content:JS JavaScript docs Content:Accessibility Accessibility docs Content:SVG SVG docs Content:Glossary Glossary entries Content:Firefox Content in the Mozilla/Firefox subtree Content:Meta Content in the meta docs Content:PWA Progressive Web Apps content system [PR only] Infrastructure and configuration for the project size/l [PR only] 501-1000 LoC changed labels Mar 26, 2025
@Josh-Cena
Copy link
Member

Force pushed to remove all the extraneous history.

Copy link
Member

@estelle estelle left a 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.
Copy link
Member

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.

Suggested change
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

Copy link
Collaborator

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.

Copy link
Member Author

@pepelsbey pepelsbey Mar 28, 2025

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));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
console.log(path.getPathSegmentAtLength(65));
console.dir(path.getPathSegmentAtLength(65));

or

Suggested change
console.log(path.getPathSegmentAtLength(65));
const pathSegment = path.getPathSegmentAtLength(65);
console.log(pathSegment.type); // output: "v"
console.log(pathSegment.value); // output: 64

Copy link
Member Author

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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- : Returns the segment at a given distance along the path.
- : Returns the {{domxref("SVGPathSegment")}} at the given distance along the path.

pepelsbey and others added 3 commits March 28, 2025 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:WebAPI Web API docs size/m [PR only] 51-500 LoC changed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants