Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Changes suggested in code review.
  • Loading branch information
JakeQZ committed Jan 21, 2025
commit 3f54b77745d05130b8df498ca5e08497c6fa9cd7
9 changes: 6 additions & 3 deletions src/Value/Color.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,14 @@ public static function parse(ParserState $oParserState, bool $bIgnoreCase = fals
// So, attempt to parse with the `a`, and allow for it not being there.
switch ($sColorMode) {
case 'rgb':
$colorModeForParsing = 'rgba';
$mayHaveOptionalAlpha = true;
break;
case 'hsl':
$colorModeForParsing = $sColorMode . 'a';
$colorModeForParsing = 'hsla';
$mayHaveOptionalAlpha = true;
break;
// These two cases are handled identically.
case 'rgba':
case 'hsla':
$colorModeForParsing = $sColorMode;
Expand All @@ -88,7 +92,6 @@ public static function parse(ParserState $oParserState, bool $bIgnoreCase = fals
default:
$colorModeForParsing = $sColorMode;
$mayHaveOptionalAlpha = false;
break;
}

$bContainsVar = false;
Expand All @@ -105,7 +108,7 @@ public static function parse(ParserState $oParserState, bool $bIgnoreCase = fals
// This must be done first, to consume comments as well, so that the `comes` test will work.
$oParserState->consumeWhiteSpace();

// With a var argument, the function can have fewer arguments.
// With a `var` argument, the function can have fewer arguments.
// And as of CSS Color Module Level 4, the alpha argument is optional.
$canCloseNow =
$bContainsVar ||
Expand Down