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

Is the path() function allowed for the d property? #939

Open
graouts opened this issue Apr 9, 2024 · 3 comments
Open

Is the path() function allowed for the d property? #939

graouts opened this issue Apr 9, 2024 · 3 comments

Comments

@graouts
Copy link

graouts commented Apr 9, 2024

The spec for the d property says:

The <string> value specifies a shape using a path data string. The contents of the <string> value must match the svg-path EBNF grammar defined below, and errors within the string are handled according to the rules in the Path Data Error Handling section. If the path data string contains no valid commands, then the behavior is the same as the none value.

Looking at the grammar I do not see any mention of the path() function. However, the bulk of the WPT coverage for the d property use the path() function and Chrome and Firefox support it.

Am I misreading the spec? Should the SVG spec allow the path() function to be used? Should the WPT coverage be updated to not use the path() function?

@JeremiePat
Copy link
Contributor

JeremiePat commented Apr 9, 2024

This is the definition of the d property used as a DOM attribute for the <path> element. In that case, yes, the CSS path() function is not supported. To my knowledge, no browser will render the following SVG document :

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10">
  <path d="path('M1,1 9,1 9,9 1,9z')" />
</svg>

The CSS path function is only allowed when the d property is used as a CSS property within a stylesheet (it's actually mandatory for parsing reasons, if I remember correctly the discussion at the CSS working group... years ago :-/ ), which make that document okay to be rendered :

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10">
  <style>
    path {
      d: path('M1,1 9,1 9,9 1,9z');
    }
  </style>
  <path />
</svg>

Not that currently, Safari doesn't support the d property as a CSS property while Chrome and Firefox do.

That said, to my knowledge there is no clear spec that summarize that behavior in CSS, and FWIW, the current SVG2 spec, even if it is the most accurate SVG spec currently available, doesn't really reflect the actual state of implementation of SVG within browsers... especially when it comes to CSS.

@graouts
Copy link
Author

graouts commented Apr 9, 2024

Not that currently, Safari doesn't support the d property as a CSS property while Chrome and Firefox do.

That's correct, but keep an eye out on WebKit bug 234227.

That said, to my knowledge there is no clear spec that summarize that behavior in CSS, and FWIW, the current SVG2 spec, even if it is the most accurate SVG spec currently available, doesn't really reflect the actual state of implementation of SVG within browsers... especially when it comes to CSS.

That's concerning! I hope this issue yields a clear specification.

@graouts
Copy link
Author

graouts commented Oct 23, 2024

I was told today about #374 which is relevant here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants