Skip to content

[css-shapes] Functional notation for Polygon: commas or no commas? #3273

@faceless2

Description

@faceless2

The definition of the polygon() function in the current draft is:

polygon( <fill-rule>? , [<length-percentage> <length-percentage>]# )

but all of the web-platform-test/css/css-masking/clip-path/clip-path-polygon-*.html files use commas to separate the <length-percentage> pairs, and this comma is required by Chrome and Firefox.

I've read all of https://lists.w3.org/Archives/Public/www-style/2013Oct/0016.html and I think the conclusion was the commas are required for polygons, but optional for other shapes. However this discussion predates #266 and the description of functional notation in css-values: "Some legacy functional notations, such as rgba(), use commas unnecessarily, but generally commas are only used to separate items in a list, or pieces of a grammar that would be ambiguous otherwise."

So:

  • If commas are required I believe the correct syntax [1] is:
polygon( <fill-rule>? , [<length-percentage> <length-percentage> ,]# )
  • If the spec is correct and commas are disallowed, then all those test cases are wrong and need updating, as do the two main browsers. Unlikely.

  • If commas between the pairs are optional, a note should be made to that effect in the spec. Given the syntax without commas has been public for some time now, there is precedent for allowing both syntaxes given that no ambiguity arises. See specifically the definition of "rect" in css-masking: "User agents must support separation with commas, but may also support separation without commas (but not a combination), because a previous revision of this specification was ambiguous in this respect."

[1] presuming I have understood the magic grammar rules regarding commas

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions