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

"class" on svelte:component doesn't seem to properly compile #7447

Closed
halvves opened this issue Apr 12, 2022 · 2 comments
Closed

"class" on svelte:component doesn't seem to properly compile #7447

halvves opened this issue Apr 12, 2022 · 2 comments

Comments

@halvves
Copy link

halvves commented Apr 12, 2022

Describe the bug

I'm fairly new to Svelte, so bear with me if this isn't really a bug, but if I try to pass a class to a component using <svelte:component />

  1. The styles don't seem to compile
  2. I get the "unused css selector" warning

I would expect to be able to pass a class to a component this way and everything compile per usual.

Reproduction

quick repro: https://svelte.dev/repl/d3b523dbff6c48c4b8ec9ec2f4eb3a0d

general idea:

<script>
  import CoolDivA from './CoolDivA.svelte';
	
  let selectedComponent = CoolDivA;
</script>

<svelte:component this={selectedComponent} class="c" />

<style>
  .c {
    color: red;
  }
</style>

Logs

No response

System Info

System:
    OS: macOS 12.2.1
    CPU: (10) arm64 Apple M1 Max
    Memory: 3.09 GB / 64.00 GB
    Shell: 5.8 - /opt/homebrew/bin/zsh
  Binaries:
    Node: 16.13.2 - /usr/local/bin/node
    npm: 8.1.2 - /usr/local/bin/npm
  Browsers:
    Chrome: 100.0.4896.88
    Firefox: 96.0.3
    Safari: 15.3

Severity

annoyance

@Conduitry
Copy link
Member

class on any component (including <svelte:component>) is just another prop. It doesn't have anything to do with the HTML class attribute, and doesn't enter into styling.

@halvves
Copy link
Author

halvves commented Apr 12, 2022

Ah, I see. It looks like I'm just encountering another variation of #2870, and this is something not currently desired in svelte core. No worries! Thanks for the quick response! Seems this workaround may do the job for me.

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

No branches or pull requests

2 participants