Skip to content

Commit

Permalink
Let CSS Color handle CSS <color> value parsing
Browse files Browse the repository at this point in the history
Our definition had issues such as not resolving currentcolor correctly when used as part of CSS color functions.

Fixes #9940.
  • Loading branch information
annevk authored Mar 5, 2024
1 parent fb3a991 commit de99ee1
Showing 1 changed file with 1 addition and 25 deletions.
26 changes: 1 addition & 25 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -3520,31 +3520,6 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
parenthesis and a missing "blue" value) cannot be parsed, as closing the open construct does not
result in a viable value.</p>

<p>To <dfn id="parsed-as-a-css-color-value">parse a CSS &lt;color> value</dfn>, given a string
<var>input</var> with an optional element <var>element</var>, run these steps:</p>

<ol>
<li><p>Let <var>color</var> be the result of <span data-x="parse something according to a CSS
grammar">parsing</span> <var>input</var> as a CSS <span>&lt;color></span>.
<ref>CSSCOLOR</ref></p></li>

<li><p>If <var>color</var> is failure, then return failure.</p></li>

<li>
<p>If <var>color</var> is <span>'currentcolor'</span>, then:</p>

<ol>
<li><p>If <var>element</var> is not given, then set <var>color</var> to <span>opaque
black</span>.</p></li>

<li><p>Otherwise, set <var>color</var> to the computed value of the <span>'color'</span>
property of <var>element</var>.</p></li>
</ol>
</li>

<li><p>Return <var>color</var>.</p></li>
</ol>

<p>The following terms and features are defined in <cite>Cascading Style Sheets</cite>
(<cite>CSS</cite>): <ref>CSS</ref></p>

Expand Down Expand Up @@ -3649,6 +3624,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
<li><dfn data-x-href="https://drafts.csswg.org/css-color/#valdef-color-srgb">'srgb'</dfn> color space</li>
<li><dfn data-x-href="https://drafts.csswg.org/css-color/#valdef-color-display-p3">'display-p3'</dfn> color space</li>
<li><dfn data-x-href="https://drafts.csswg.org/css-color/#valdef-color-profile-rendering-intent-relative-colorimetric">'relative-colorimetric'</dfn> rendering intent</li>
<li><dfn id="parsed-as-a-css-color-value" data-x-href="https://drafts.csswg.org/css-color/#parse-a-css-color-value">parse a CSS &lt;color> value</dfn></li>
</ul>

<p>The following terms are defined in <cite>CSS Images</cite>: <ref>CSSIMAGES</ref></p>
Expand Down

0 comments on commit de99ee1

Please sign in to comment.