Skip to content

Commit

Permalink
<path d> parsing spec needs a special case to not use CSS syntax
Browse files Browse the repository at this point in the history
When reading the spec literally before this changes,
https://svgwg.org/svg2-draft/styling.html#PresentationAttributes
specifies that all presentation properties are parsed according to
https://svgwg.org/svg2-draft/types.html#presentation-attribute-css-value

For the `d` property, this means the CSS grammar `none | <string>`.

The following would be valid:

* `<path d="none">`
* `<path d="'M 100 100 L 300 100 L 200 300 z'">` (not the single quotes)
* `<path d="/**/'M 100 100 \L \3300 100 L 200 300 z'">` (equivalent to the previous)

But `<path d="M 100 100 L 300 100 L 200 300 z">` or indeed any SVG 1.1 path
would not be valid because they parse as CSS ident and number tokens,
not as a `<string>`.

w3c#320 poposes changing the syntax
of the `d` CSS propery to be even further to the existing attribute syntax.
  • Loading branch information
SimonSapin committed Dec 27, 2018
1 parent 61200d7 commit 5e0ef74
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions master/styling.html
Expand Up @@ -314,8 +314,9 @@ <h2 id="PresentationAttributes">Presentation attributes</h2>
<p>Since presentation attributes are parsed as CSS values, not declarations, an
<a href="https://www.w3.org/TR/2011/REC-CSS2-20110607/cascade.html#important-rules"><span class="prop-value">!important</span> declaration</a>
within a presentation attribute will cause it to have an <a>invalid value</a>.
See <a href="types.html#presentation-attribute-css-value">Attribute syntax</a>
for details on how presentation attributes are parsed.</p>
Except as noted in thetable for the <a>'d'</a> presentation attribute,
the value of presentation attributes is parsed
<a href="types.html#presentation-attribute-css-value">using the CSS Value Definition Syntax</a>.

<p>Not all style properties that can affect SVG rendering have a corresponding
presentation attribute.
Expand Down Expand Up @@ -382,6 +383,20 @@ <h2 id="PresentationAttributes">Presentation attributes</h2>
</td>
<td>
<a>'path'</a>
<p>
Unlike other presentation attributes,
the value is not parsed as CSS syntax
but directly according to the <a href="#PathDataBNF">svg-path</a>
<a href="types.html#syntax">EBNF grammar</a>,
and errors within the string are handled according to the rules in the
<a href="paths.html#PathDataErrorHandling">Path Data Error Handling</a> section.
</p>
<p class="note">
In particular, the attribute value does not accept the <code>none</code> keyword,
does not have the quotes of a CSS <a>&lt;string&gt;</a> token
(in addition to those delimiting the attribute value in XML or HTML syntax),
and does not unescape CSS backslash-escapes.
</p>
</td>
</tr>
<tr>
Expand Down

0 comments on commit 5e0ef74

Please sign in to comment.