Skip to content
Merged
Changes from all commits
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
15 changes: 9 additions & 6 deletions src/Value/Color.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,12 +224,7 @@ public function __toString(): string

public function render(OutputFormat $outputFormat): string
{
// Shorthand RGB color values
if (
$outputFormat->getRGBHashNotation()
&& $this->getRealName() === 'rgb'
&& $this->allComponentsAreNumbers()
) {
if ($this->shouldRenderAsHex($outputFormat)) {
return $this->renderAsHex();
}

Expand All @@ -240,6 +235,14 @@ public function render(OutputFormat $outputFormat): string
return parent::render($outputFormat);
}

private function shouldRenderAsHex(OutputFormat $outputFormat): bool
{
return
$outputFormat->getRGBHashNotation()
&& $this->getRealName() === 'rgb'
&& $this->allComponentsAreNumbers();
}

/**
* The function name is a concatenation of the array keys of the components, which is passed to the constructor.
* However, this can be changed by calling {@see CSSFunction::setName},
Expand Down