Skip to content

Color names not working with ExpandShorthands #510

Closed as not planned
Closed as not planned
@BenPayton

Description

@BenPayton

I'm using this parser in a project to optimize and pull data from hundreds of old CSS files, most of which make use of only hex and named colors.

CSS example:

.selector {
    color: white;
    background: red url('image.jpg') 50px 150px repeat-x;
    border: 1px solid darkred;
}

After expandShorthands()

.selector {
    color: white;
    border-top-style: darkred;
    border-right-style: darkred;
    border-bottom-style: darkred;
    border-left-style: darkred;
    border-top-width: 1px;
    border-right-width: 1px;
    border-bottom-width: 1px;
    border-left-width: 1px;
    background-color: transparent;
    background-image: url("image.jpg");
    background-repeat: repeat-x;
    background-attachment: scroll;
    background-position: 50px 150px;
}

If a selector has shorthand border or background properties that use color names, border colors become border-style values and background colors are dropped entirely and replaced with "transparent".

My current workaround for this is to use a custom class to parse the value strings and convert any color names to hex values before running expandShorthands().

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugwontfixBug reports that maintainers have agreed by consensus are not bugs in the library

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions