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

inlineStyles plugin should not inline styles when pseudo-classes target the element #2067

Open
johnkenny54 opened this issue Aug 22, 2024 · 0 comments
Labels

Comments

@johnkenny54
Copy link
Contributor

When pseudo-classes target an element, moving a style inline will disable the style in the pseudo-class selector (since styles in attributes have the greatest specificity).

To Reproduce
Process the following file with the inlineStyles plugin:

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
  <style>
    #a {stroke:red;}
    #a:hover {stroke:green;}
    circle {fill:blue;}
    circle:active {fill:yellow;}
    g :first-child {stroke:orange;}
    g :first-child:hover {stroke:pink;}
    path.a {stroke:purple;}
    path.a:hover {stroke:silver;}
    path.a + path {stroke:lime;}
    path.a:hover + path {stroke:gray;}
  </style>
  <path id="a" d="M 2 2 h10"/>
  <circle cx="5" cy="10" r="1"/>
  <g>
    <path d="M 2 4 h10"/>
  </g>
  <path class="a" d="M 2 6 h10"/>
  <path d="M 2 8 h10"/>
</svg>

Expected behavior
No styles are inlined, since doing so disables the hover/click effects of the pseudo-classes.

SVGO Version 4.0.0-rc.1

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

No branches or pull requests

1 participant