Skip to content

[css-typed-om] the CSSColor constructor is wrong #1032

@svgeesus

Description

@svgeesus

In 4.6 CSSColorValue objects, the CSSColor constructor is given as

[Exposed=(Window, Worker, PaintWorklet, LayoutWorklet)]
interface CSSColor : CSSColorValue {
    constructor
(sequence<(DOMString or CSSNumberish)> variant
);
    /* CSSColor(["foo", 0, 1, .5], ["bar", "yellow"], 1, fallbackColor) */
    /* or just make the alpha and fallback successive optional args? */
};

This has several problems.

Firstly, the colorspace slot is not named which makes it hard to refer to it; in CSS Color 4 the colorspace parameter to color() is mandatory.

Secondly, the alpha is also not named, but needs to be so that the various toFoo methods can require that it be filled in. And yes it should be an optional argument.

Thirdly, the non-normative comment uses the old syntax with multiple fallbacks. It also uses a colorspace "foo" which is not a dashed ident, nor is it a prefefined colorspace, so Typed OM would currently return a SyntaxError. I suggest replacing the comment with

/* CSSColor(["display-p3", 0, 1, .5] */

So the constructor should take:

  1. The colorspace
  2. The parameters (if the intent really is to restrict to predefined RGB spaces, these could be called r g and b; but that also cuts out xyz and lab from being represented. Otherwise, make them a sequence of parameters
  3. Optionally, the alpha

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