Skip to content

background: rgb(var(--my-var, 0, 0, 0)); parses as valid for both background-color and background-image #199

@bryan-codaio

Description

@bryan-codaio

In react we've got a component that does effectively

<div style={{background: 'rgb(var(--my-var, 0, 0, 0));'}} />

and when we later coerce that to a string per jest snapshot tests, we get back

<div style="background: rgb(var(--my-var, 0, 0, 0)) rgb(var(--my-var, 0, 0, 0));"></div>

Best I can tell this is due to it being parsed as valid for both background-color and background-image per

if (type === exports.TYPES.NULL_OR_EMPTY_STR || type === exports.TYPES.VAR) {
. I.e. the value in question is being detected as a variable (which isn't completely inaccurate, given its use of var() internally). However, the wrapping rgb should indicate it's not valid for background-image?

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