-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Lobotomized owl CSS selector broken #3104
Comments
Maybe you will need to use the :global() modifier: <style>
.user-section {
display: flex;
}
.user-section > :global(* + *) {
margin-left: 4px;
}
</style> |
Following the way the css selectors works, something like: 1-
2-
Each +, >, ~ "breaks" the selector in single parts. Svelte match the entire selector, but can replace each part of it with the class hash. So, using the :global() modifier, you let svelte know you want that selector to keep on the code as it is! And just one more thing to keep documented, lol. The class selectors, like |
It does indeed look like the issue here is that App.svelte <script>
import Foo from './Foo.svelte';
</script>
<Foo/>
<div>
bar
</div>
<style>
div + div {
color: red;
}
</style> Foo.svelte <div>
foo
</div> The styles shouldn't match anything, but they do. The In general, it seems like these combinators are getting handled by ignoring everything but the last part when seeing which parts of the document they might match, and then it's also only this last part of the selector that gets scoped. |
There's a rather telling comment here which I don't remember really absorbing before. Only |
I was just thinking about this more, and there seem to be a lot more things to worry about with sibling selectors than with the other ones. For example: {#each foo as bar}
<div class='a'>...</div>
<div class='b'>...</div>
{/each} then |
|
I like to use a pattern of a CSS flex-box with whildren evenly spaced using the lobotomized owl selector.
My CSS looks like this:
Svelte compiles it into this:
The right eye of the owl is replaced with the unique Svelte-generated selector id for the flexbox. I expected the unique id to be appended to the flexbox selector before the
>
part of the selector.Is the id just naively appended to the end of the selector? Maybe a whitespace collapse is set to happen too early when handling this selector.
Svelte version: 3.5.3
The text was updated successfully, but these errors were encountered: