Skip to content

Color previews reject valid out-of-range RGB channels #584

Backlog

Description

Reproduction

On current main (f272767), findDocumentColors returns no colors for valid RGB functions with channels outside the nominal range:

import { getCSSLanguageService, TextDocument } from './lib/esm/cssLanguageService.js';

const service = getCSSLanguageService();
const document = TextDocument.create('test:///example.css', 'css', 0,
  '.a { color: rgb(300, -20, 0); }');
console.log(service.findDocumentColors(document, service.parseStylesheet(document)));
// Actual: []

The same happens for percentage channels (rgb(120%, -10%, 0%)) and modern space-separated syntax, including in the SCSS and Less services.

Expected

Return a color preview with { red: 1, green: 0, blue: 0, alpha: 1 } for these examples. CSS Color 4 requires out-of-range RGB components to be clamped, not rejected. Chromium also accepts and clamps these values.

This concerns RGB channels only, independently of alpha handling in #581. I have a focused fix with regression coverage ready.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions