Skip to content

Conversation

Conduitry
Copy link
Member

Resolves #4314.

Note that this doesn't actually fix what's described in the OP (which isn't a bug), but rather what I described in my comment - namely, that selectors like :global(.foo) .bar aren't getting correctly marked as unused if nothing matched .bar.

I'm a little concerned that the fix might not be as simple as this PR is making it out to be, but I'm hoping it is.

@Conduitry Conduitry merged commit be9b79f into sveltejs:master Jan 27, 2020
@Conduitry Conduitry deleted the gh-4314 branch January 27, 2020 23:25
jesseskinner pushed a commit to jesseskinner/svelte that referenced this pull request Feb 27, 2020
@dekdevy
Copy link

dekdevy commented Mar 6, 2020

Running into an issue here, i just updated from 3.16 to 3.19.

I have this scss class:

:global(.subnav) {
  display:flex;
  &>input, &>select {
    width: auto;
  }
  &:not(:first-child) {
    margin-top:8px;
  }
}

And this svelte code:

  <div class=subnav>
    <input>
  </div>

In 3.16, this is the resulting CSS:

.subnav {
    display: flex
}

.subnav>input,.subnav>select {
    width: auto
}

.subnav:not(:first-child) {
    margin-top: 8px
}

In 3.19, this is the resulting CSS:

.subnav {
    display: flex
}
.subnav:not(:first-child) {
    margin-top: 8px
}

Any ideas?

@Conduitry
Copy link
Member Author

What is the preprocessor turning that into before it gets to the compiler? If you think you can reproduce an issue in the REPL using regular CSS, please open an issue.

@schliflo
Copy link

schliflo commented May 4, 2020

@Conduitry I am having the same issue as @dekdevy mentioned with external scss files that have :global() styles.
I'ts not possible to reproduce via REPL as one cannot create external styles there, but I'd be happy to provide an example repo with minimal setup outlining this issue.
I'm fairly certain this change is responsible for the bug, as everything works as expected in 3.18.0 but breaks starting from 3.18.1 where this change landed.
Let me know if you need an example repo for further investigation.

@Conduitry
Copy link
Member Author

This PR changed the handling of certain styles in <style> blocks within Svelte components. Once preprocessors are run, the styles in these blocks are the only styles that the compiler touches, can see, or knows about. Any change in behavior that is the result of this PR can be seen in a vanilla Svelte component.

taylorzane pushed a commit to taylorzane/svelte that referenced this pull request Dec 17, 2020
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 this pull request may close these issues.

:global(...) .child selector is given svelte- suffix if there is a variable class name in the html

3 participants