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

@media css class inline error #1834

Open
rwv opened this issue Nov 14, 2023 · 0 comments · May be fixed by #2056
Open

@media css class inline error #1834

rwv opened this issue Nov 14, 2023 · 0 comments · May be fixed by #2056
Labels

Comments

@rwv
Copy link

rwv commented Nov 14, 2023

Describe the bug
svgo doesn't handle @media css class correctly

To Reproduce

svgo the following svg

<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 24 24">
    <style>
        .fill {
            fill: #1f2225
        }

        @media (prefers-color-scheme:dark) {
            .fill {
                fill: #e8e8e8
            }
        }
    </style>
    <path
        d="M13 3.5a3.5 3.5 0 0 0-2.669 5.764a.75.75 0 0 1-.571 1.236H3.75a.25.25 0 0 0-.25.25v1c0 2.9 2.35 5.25 5.25 5.25h3.218c.15.11.319.196.504.255a9.129 9.129 0 0 0-.727 1.245H8.75A6.75 6.75 0 0 1 2 11.75v-1C2 9.784 2.784 9 3.75 9h4.666a5 5 0 1 1 9.168-4h1.666c.966 0 1.75.784 1.75 1.75a2.75 2.75 0 0 1-2.75 2.75h-.92c-.135.235-.29.458-.461.667c.157.137.305.284.442.44c-.176.019-.356.04-.54.065a7.01 7.01 0 0 0-1.323.306a3.047 3.047 0 0 0-.1-.058a.75.75 0 0 1-.11-1.23A3.502 3.502 0 0 0 16.355 8h1.895c.69 0 1.25-.56 1.25-1.25a.25.25 0 0 0-.25-.25h-2.785A3.5 3.5 0 0 0 13 3.5zm3.901 8.163c2.801-.37 4.539-.06 5.563.227a.75.75 0 0 1 .212 1.348c-.057.038-.15.13-.26.34c-.11.208-.213.48-.32.825c-.088.284-.17.59-.261.925l-.057.212c-.112.41-.234.85-.382 1.286c-.292.862-.704 1.782-1.397 2.488c-.72.733-1.695 1.19-3 1.19c-1.328 0-2.256-.539-2.85-1.159c-.403.74-.613 1.437-.645 1.951a.75.75 0 0 1-1.497-.091c.07-1.14.665-2.574 1.662-3.844c1.009-1.284 2.48-2.467 4.381-3.04a.75.75 0 0 1 .433 1.436c-1.448.437-2.61 1.312-3.452 2.308c.31.442.922.939 1.969.939c.911 0 1.498-.302 1.928-.74c.457-.466.78-1.13 1.047-1.92c.132-.389.245-.791.355-1.197l.055-.201c.09-.335.181-.674.278-.987c.09-.291.192-.583.314-.853c-.893-.13-2.15-.184-3.879.044c-1.998.265-3.124 1.723-3.375 2.635a.75.75 0 0 1-1.446-.398c.396-1.442 1.978-3.373 4.624-3.724z"
        class="fill">
    </path>
</svg>

result (reformatted)

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
    <path
        d="M13 3.5a3.5 3.5 0 0 0-2.669 5.764.75.75 0 0 1-.571 1.236H3.75a.25.25 0 0 0-.25.25v1c0 2.9 2.35 5.25 5.25 5.25h3.218c.15.11.319.196.504.255a9.129 9.129 0 0 0-.727 1.245H8.75A6.75 6.75 0 0 1 2 11.75v-1C2 9.784 2.784 9 3.75 9h4.666a5 5 0 1 1 9.168-4h1.666c.966 0 1.75.784 1.75 1.75a2.75 2.75 0 0 1-2.75 2.75h-.92c-.135.235-.29.458-.461.667.157.137.305.284.442.44-.176.019-.356.04-.54.065a7.01 7.01 0 0 0-1.323.306 3.047 3.047 0 0 0-.1-.058.75.75 0 0 1-.11-1.23A3.502 3.502 0 0 0 16.355 8h1.895c.69 0 1.25-.56 1.25-1.25a.25.25 0 0 0-.25-.25h-2.785A3.5 3.5 0 0 0 13 3.5zm3.901 8.163c2.801-.37 4.539-.06 5.563.227a.75.75 0 0 1 .212 1.348c-.057.038-.15.13-.26.34a4.94 4.94 0 0 0-.32.825c-.088.284-.17.59-.261.925l-.057.212c-.112.41-.234.85-.382 1.286-.292.862-.704 1.782-1.397 2.488-.72.733-1.695 1.19-3 1.19-1.328 0-2.256-.539-2.85-1.159-.403.74-.613 1.437-.645 1.951a.75.75 0 0 1-1.497-.091c.07-1.14.665-2.574 1.662-3.844 1.009-1.284 2.48-2.467 4.381-3.04a.75.75 0 0 1 .433 1.436c-1.448.437-2.61 1.312-3.452 2.308.31.442.922.939 1.969.939.911 0 1.498-.302 1.928-.74.457-.466.78-1.13 1.047-1.92.132-.389.245-.791.355-1.197l.055-.201c.09-.335.181-.674.278-.987.09-.291.192-.583.314-.853-.893-.13-2.15-.184-3.879.044-1.998.265-3.124 1.723-3.375 2.635a.75.75 0 0 1-1.446-.398c.396-1.442 1.978-3.373 4.624-3.724z"
        style="fill:#1f2225" />
</svg>

style tag is inlined and @media query is not working.

Expected behavior
keep @media css

Desktop (please complete the following information):

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

Successfully merging a pull request may close this issue.

1 participant