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

usageClassName not applied correctly #158

Closed
filoxo opened this issue Mar 19, 2023 · 0 comments
Closed

usageClassName not applied correctly #158

filoxo opened this issue Mar 19, 2023 · 0 comments

Comments

@filoxo
Copy link

filoxo commented Mar 19, 2023

Expected behavior

When usageClassName is provided, the output svg spritesheet should use it to generate the target styles.

Current behavior

When usageClassName is provided, the output svg spritesheet does not use it but instead uses the default value.

Steps to reproduce

Using the following config:

const spritesheet = await mixer('src/svg/*.svg', 
  {
    spriteType: 'stack', 
    spriteConfig: {
      usages: false,
      usageClassName: 'icon-sprite',
    },
  }
)

My spritesheet is emitting the following (formatted for clarity):

<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
  <defs>
    <style>.sprite-symbol-usage {display: none;}
.sprite-symbol-usage:target {display: inline;}</style>
  </defs>
  <svg viewBox="0 0 24 24" id="icon-id" class="icon-sprite"><path d="..." /></svg>
</svg>

Note that the style definition uses .sprite-symbol-usage but the class applied to the inner svg element is icon-spite as configured.

The traced the issue back to this config setup: https://github.com/JetBrains/svg-mixer/blob/master/packages/svg-mixer/lib/stack-sprite.js#L16-L22 I'm not an expert with classes but I think what is happening is that the getter's this will refer to the original object that encloses it, and not a reference to the class after merge. I have a fix but ultimately couldn't get tests working so will submit a PR and hope CI can validate it.

@filoxo filoxo closed this as not planned Won't fix, can't repro, duplicate, stale Mar 16, 2024
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

Successfully merging a pull request may close this issue.

1 participant