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

Remove inline styles to support strict CSP #306

Closed
marekdedic opened this issue Nov 2, 2023 · 7 comments
Closed

Remove inline styles to support strict CSP #306

marekdedic opened this issue Nov 2, 2023 · 7 comments
Labels
enhancement New feature or request

Comments

@marekdedic
Copy link
Contributor

Hi, I would like to use CSP for my site, however, svelte-fa contains inline styles that prevent me from removing unsafe-inline from my style-src. Could you please remove inline styles?

A quick search through the code reveals several candidates for the offending lines:

style={s}

<span style={s}>

Thanks!

@marekdedic
Copy link
Contributor Author

To clarify, the usual way around this is to use class:some={true} to dynamically style elements - the classes aren't inline

@Cweili
Copy link
Owner

Cweili commented Nov 6, 2023

We support inline style to meet the following use cases:

<FaLayers size="4x" style="background: mistyrose">
  <Fa icon={faEnvelope} />
  <FaLayersText scale={0.2} translateX={0.4} translateY={-0.4} color="white" style="padding: 0 .2em; background: tomato; border-radius: 1em">
    1,419
  </FaLayersText>
</FaLayers>

https://cweili.github.io/svelte-fa/#layering---text

@marekdedic
Copy link
Contributor Author

Hmm, yeah, if values are passed to the component directly, that's unfortunately a little bit complicated - I see only one option that doesn't violate the CSP - add them with a JS function (see https://stackoverflow.com/a/57633533)

@marekdedic
Copy link
Contributor Author

Would you be willing to accept a PR?

@Cweili
Copy link
Owner

Cweili commented Nov 13, 2023

@marekdedic Yes, please feel free to submit a PR!

@Cweili Cweili added the enhancement New feature or request label Nov 29, 2023
@Cweili
Copy link
Owner

Cweili commented Dec 19, 2023

@marekdedic Please see #308 (comment)

@Cweili
Copy link
Owner

Cweili commented Jan 5, 2024

Released with v4. Thanks!

@Cweili Cweili closed this as completed Jan 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants