Visitar URL original
escaped dashicon not working · Issue #455 · css/csso · GitHub
Skip to content

escaped dashicon not working #455

Open

Description

@mmjaeger

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.

Activity

  1. mmjaeger commented on May 18, 2022

    @mmjaeger
    Author

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

  2. dryabov commented on May 19, 2022

    @dryabov

    Do you apply CSSO before CSS preprocessor?

  3. mmjaeger commented on May 19, 2022

    @mmjaeger
    Author
  4. dryabov commented on May 19, 2022

    @dryabov

    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").

  5. mmjaeger commented on May 19, 2022

    @mmjaeger
    Author
  6. mmjaeger commented on May 19, 2022

    @mmjaeger
    Author
  7. dryabov commented on May 19, 2022

    @dryabov

    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.

  8. lahmatiy commented on Jul 14, 2022

    @lahmatiy
    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"

  9. mmjaeger commented on Oct 11, 2022

    @mmjaeger
    Author
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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