Description
Nested declarations in CSS combine with spaces, so I would expect the following to work:
.scopedClass {
:global {
.globalClass {...}
}
}
In this case, I'd expect scopedClass to be hashed and globalClass to be left unchanged, because the selector should be equivalent to .scopedClass :global .globalClass (the selector-less block left over is debatable but it seems like the easiest approach):
.scopedClass_1t7w5_1 {
{
.globalClass {...}
}
}
However, in practice, CSS Modules does not recognize the global scope for the nested class and hashes both scopedClass and globalClass:
.scopedClass_1t7w5_1 {
{
.globalClass_1t7w5_2 {...}
}
}
Use-case
If this worked, it could be an extremely useful feature for working with UI from external libraries. I could apply a hashed container class around the entire component, then apply unhashed styles within the component, thus encapsulating my styling with no repetition. Take CodeMirror as an example:
.codeMirrorContainer :global {
.cm-editor {...}
.cm-line {...}
.cm-placeholder {...}
}
To make this work currently, I have to repeat global for every selector:
.codeMirrorContainer {
:global .cm-editor {...} /* or `:global(.cm-editor)` */
:global .cm-line {...}
:global .cm-placeholder {...}
}
Description
Nested declarations in CSS combine with spaces, so I would expect the following to work:
In this case, I'd expect
scopedClassto be hashed andglobalClassto be left unchanged, because the selector should be equivalent to.scopedClass :global .globalClass(the selector-less block left over is debatable but it seems like the easiest approach):However, in practice, CSS Modules does not recognize the global scope for the nested class and hashes both
scopedClassandglobalClass:Use-case
If this worked, it could be an extremely useful feature for working with UI from external libraries. I could apply a hashed container class around the entire component, then apply unhashed styles within the component, thus encapsulating my styling with no repetition. Take CodeMirror as an example:
To make this work currently, I have to repeat
globalfor every selector: