Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use parsers.parseColor() in border-color parsing, like background-color #185

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

bawjensen
Copy link

My attempt at fixing #184. Please feel free to use this code however ends up most useful.

}
if (
parsers.valueType(v) === parsers.TYPES.KEYWORD &&
(v.toLowerCase() === 'transparent' || v.toLowerCase() === 'inherit')
Copy link
Contributor

@asamuzaK asamuzaK Feb 6, 2025

Choose a reason for hiding this comment

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

I think we don't need v.toLowerCase() === 'transparent'.
It's already resolved by css-color.

To make sure, add test like below somewhere around test/parsers.js#L64

  it('returns color for transparent keyword', () => {
    let input = 'transparent';
    let output = parsers.valueType(input);

    assert.strictEqual(output, parsers.TYPES.COLOR);
  });

And before test/parsers.js#L248 i.e. it.todo('Add more tests')

  it('should output transparent keyword', () => {
    let input = 'transparent';
    let output = parsers.parseColor(input);

    assert.strictEqual(output, 'transparent');
  });

Copy link
Author

Choose a reason for hiding this comment

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

I had effectively copy/pasted this from the background-color logic. Should I update that too, to keep in sync? (I've proactively updated it, but as a separate commit that should be easy to revert if needed)

thanks for the review!

Copy link
Contributor

@asamuzaK asamuzaK left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants