From 2f429625fd33e84244c934e29e34748cf5bbc353 Mon Sep 17 00:00:00 2001 From: Conduitry Date: Sun, 10 Sep 2023 17:51:33 -0400 Subject: [PATCH] scoping scoping scoping --- documentation/docs/05-misc/01-faq.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentation/docs/05-misc/01-faq.md b/documentation/docs/05-misc/01-faq.md index 3e4dba6464..100fca325e 100644 --- a/documentation/docs/05-misc/01-faq.md +++ b/documentation/docs/05-misc/01-faq.md @@ -137,7 +137,7 @@ No. Svelte removes the styles from the component and warns you about them in ord Svelte's component style scoping works by generating a class unique to the given component, adding it to the relevant elements in the component that are under Svelte's control, and then adding it to each of the selectors in that component's styles. When the compiler can't see what elements a style selector applies to, there would be two bad options for keeping it: -- If it keeps the selector and adds the scoping scoping class to it, there is no guarantee that the selector will match the expected elements in the component, and they definitely won't if they were created by a child component or `{@html ...}`. +- If it keeps the selector and adds the scoping class to it, there is no guarantee that the selector will match the expected elements in the component, and they definitely won't if they were created by a child component or `{@html ...}`. - If it keeps the selector without adding the scoping class to it, the given style will become a global style, affecting your entire page. If you need to style something that Svelte can't identify at compile time, you will need to explicitly opt into global styles by using `:global(...)`. But also keep in mind that you can wrap `:global(...)` around only part of a selector. `.foo :global(.bar) { ... }` will style any `.bar` elements that appear within the component's `.foo` elements. As long as there's some parent element in the current component to start from, partially global selectors like this will almost always be able to get you what you want.