Skip to content

[BUGFIX] Resolve issue with empty default value for var() - #1659

Merged
oliverklee merged 11 commits into
MyIntervals:mainfrom
samuil-banti-wpenigne:resolve-issue-with-empty-default-value-for-var-method
Nov 2, 2026
Merged

oliverklee merged 11 commits into
MyIntervals:mainfrom
samuil-banti-wpenigne:resolve-issue-with-empty-default-value-for-var-method

Conversation

@samuil-banti-wpenigne

Copy link
Copy Markdown
Contributor

CSS allows the default value of var to be empty i.e.

  /* A: empty fallback, --w is undefined */
  .a { border: var(--w,) solid red; }

  /* B: empty fallback, --w is defined */
  .b { --w: 5px; border: var(--w,) solid red; }

The goal of the PR is to enable us to parse such cases.

@coveralls

coveralls commented Oct 28, 2026 •

Copy link
Copy Markdown

Coverage Status

coverage: 76.388% (+0.7%) from 75.673% — samuil-banti-wpenigne:resolve-issue-with-empty-default-value-for-var-method into MyIntervals:main

@JakeQZ JakeQZ left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again for another excellent contribution; you have been quite prolific, @samuil-banti-wpenigne <3.

The code changes look near-perfect. But I think the tests could be extended and improved. See individual comments.

Comment thread tests/Unit/Value/CSSFunctionTest.php Outdated
Comment on lines +47 to +49
public function parsesEmptyVarFallback(): void
{
$parserState = new ParserState('var(--w,)', Settings::create());

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test belongs in Sabberworm\CSS\Tests\Functional\Value\CSSFunctionTest because it depends on ParserState. Putting it there will involve creating that TestCase class since it does not yet exist.

Comment thread tests/Unit/Value/CSSFunctionTest.php Outdated

$result = CSSFunction::parse($parserState);

self::assertSame('var(--w,)', $result->render(OutputFormat::createCompact()));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test should only be testing the parsing, not also the rendering. We can do $result->getArrayRepresentation() and make assertions on the returned array representation.

Comment thread CHANGELOG.md Resolved
Comment thread src/Value/Value.php Resolved
Comment thread src/Value/CSSFunction.php Resolved

@JakeQZ JakeQZ left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good now. But I think we need a converse test for CSSFunction. And there's a typo in the changelog entry.

Comment thread CHANGELOG.md Resolved
@JakeQZ JakeQZ added enhancement css4 Relating to features introduced in CSS4 labels Nov 2, 2026

@JakeQZ JakeQZ left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super. Thanks again for contributing <3.

@JakeQZ
JakeQZ requested a review from oliverklee November 2, 2026 13:26

@oliverklee oliverklee left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @samuil-banti-wpenigne! ❤️

@oliverklee
oliverklee merged commit 447372f into MyIntervals:main Nov 2, 2026
26 checks passed
@oliverklee oliverklee changed the title Resolve issue with empty default value for var() [BUGFIX] Resolve issue with empty default value for var() Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

css4 Relating to features introduced in CSS4 enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants