-
-
Notifications
You must be signed in to change notification settings - Fork 20
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
Pass attributes to Svelte components #5
Comments
I will take a look at it in the coming days 👍 |
@vabatta I don't know if this is such a good idea. I think it will be difficult to manage this in an efficient way since you need to parse all attributes in the SVG to merge the values if the attribute passed from the Svelte component already exists in the SVG node. Take your What I usually do is wrapping the SVG so I can style it from the parent node: <div class="svg-wrapper">
<MySvg />
</div>
<style>
.svg-wrapper {
:global(svg) {
// svg style
}
}
</style> Let me know if you have a good argument for forwarding attributes to the SVG and I will reconsider 👍 |
I would leave the job of making sure With this said, I would definitely add the possibility and then the dev needs to make sure he's not breaking things :) |
Hi @poppa, I was just palying around with this plugin and I expected this to have already been implemented honestly. For instance, vite-plugin-svelte-svg and rollup-plugin-svelte-svg have this feature. It's very straightforward to implement, all you have to do is add a Here's how "vite-plugin-svelte-svg" does it: see As simple as it gets. |
You don't, just put |
Hi @AradAral. You are more than welcome to create a PR 👍 |
|
@Tropix126 Well, you use |
Thank you @poppa for implementing this! 💙 |
Hi,
I was wondering if it would be possible to pass attributes to the SVG when loaded as Svelte components.
For example:
The text was updated successfully, but these errors were encountered: