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

escaped dashicon not working #455

Open
mmjaeger opened this issue May 16, 2022 · 9 comments
Open

escaped dashicon not working #455

mmjaeger opened this issue May 16, 2022 · 9 comments

Comments

@mmjaeger
Copy link

Hello
the following code isn't working after compressing:
`a.read-more {
font-size: 0.8em;
text-transform: uppercase;

&:after {
    font-family: "dashicons";
    content: '\f344'; // arrow-right
    display: inline-block;
    -webkit-font-smoothing: antialiased;
    font: normal 16px/1;
    vertical-align: middle;

   margin-bottom: 2px;
    margin-left: 5px;    
}

}`

this line fails: content: '\f344'; // arrow-right - it ends up as empty string !!

how this gets fixed soon.

@mmjaeger
Copy link
Author

actually that's not all - the whole font-family declaration is stripped as well !!!!!

@dryabov
Copy link

dryabov commented May 19, 2022

Do you apply CSSO before CSS preprocessor?

@mmjaeger
Copy link
Author

mmjaeger commented May 19, 2022 via email

@dryabov
Copy link

dryabov commented May 19, 2022

Seems I've found where the issue comes from. Usually the font property (in your example it is font: normal 16px/1) overrides all previous font-* properties. But in you example the font rule is malformed (font family is not specified), and so the browser drops it and uses previous font-family rule. In turn, CSSO firstly detects that font rule exist and previous font-family rule may be removed, and then it founds that font is malformed and may be safely removed too. As a result, both font-related properties are removed.

Most likely, the simplest solution is to fix the font property, e.g. by including font family there (font: normal 16px/1 "dashicons").

@mmjaeger
Copy link
Author

mmjaeger commented May 19, 2022 via email

@mmjaeger
Copy link
Author

mmjaeger commented May 19, 2022 via email

@dryabov
Copy link

dryabov commented May 19, 2022

Look at this line in your CSS code:

      font: normal 16px/1;

It's malformed, because it doesn't contain the font family, though CSS spec requires it.

@lahmatiy
Copy link
Member

  1. You need to change an order of your font declarations. Since font is a shorthand, it overrides any font-* declaration before itself. So any browser will discard font-family before font.

Discard font-family:
image

Apply font-family:
image

  1. As mentioned by @dryabov, a font declaration is invalid. You can test it here:

image

To fix it, you need to add any valid value for the font-family (the value doesn't make sense if font-family declaration goes next), e.g.:
image

Combine font and font-family is also an option: font: normal 16px/1 "dashicons"

@mmjaeger
Copy link
Author

mmjaeger commented Oct 11, 2022 via email

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

No branches or pull requests

3 participants