Skip to content

Commit fa11ca0

Browse files
committed
[css-color] Warn against defining your stringifiers for your own classes.
1 parent 8f2ed82 commit fa11ca0

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

css-color/Overview.bs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3154,9 +3154,13 @@ Adding New Color Classes</h4>
31543154
and a <code>toTheOtherColor()</code> method on <code>MyNewColor.prototype</code>.
31553155

31563156
<li>
3157-
Custom stringifiers on the <code>stringifiers</a> object,
3158-
if it's more accurate/efficient to convert your color class into one of the stringifier types directly
3157+
Custom stringifiers on the <code>stringifiers</a> object for one of the UA-defined color classes,
3158+
if it's more accurate/efficient to convert your color class into one of the UA-defined types directly
31593159
than it is to first convert it into an <a idl>RGBColor</a>.
3160+
3161+
Note: It is <strong>not</strong> generally useful to define a special stringifier for your class itself;
3162+
the main purpose of the stringifier is to allow the object to be used in a CSS property,
3163+
and only the UA-defined color classes correspond to valid CSS syntaxes.
31603164
</ul>
31613165

31623166
All of these apply to our example HSV color class,

css-color/Overview.html

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3262,9 +3262,13 @@ <h4 class="heading settled heading" data-level=15.5.2 id=api-adding-classes><spa
32623262
and a <code>toTheOtherColor()</code> method on <code>MyNewColor.prototype</code>.
32633263

32643264
<li>
3265-
Custom stringifiers on the <code>stringifiers object,
3266-
if it’s more accurate/efficient to convert your color class into one of the stringifier types directly
3265+
Custom stringifiers on the <code>stringifiers object for one of the UA-defined color classes,
3266+
if it’s more accurate/efficient to convert your color class into one of the UA-defined types directly
32673267
than it is to first convert it into an <a data-link-type=idl href=#dom-rgbcolor title=rgbcolor>RGBColor</a>.
3268+
3269+
<p class=note>Note: It is <strong>not</strong> generally useful to define a special stringifier for your class itself;
3270+
the main purpose of the stringifier is to allow the object to be used in a CSS property,
3271+
and only the UA-defined color classes correspond to valid CSS syntaxes.</p>
32683272
</code></ul><code>
32693273

32703274
<p>All of these apply to our example HSV color class,

0 commit comments

Comments
 (0)