mirror of
https://github.com/swc-project/swc.git
synced 2024-11-24 02:06:08 +03:00
fix(css/modules): Support composes when using multiple subclass selectors (#7949)
This commit is contained in:
parent
418a2e3016
commit
05ca19b844
@ -204,13 +204,13 @@ where
|
||||
n.visit_mut_children_with(self);
|
||||
|
||||
if let QualifiedRulePrelude::SelectorList(sel) = &n.prelude {
|
||||
//
|
||||
if sel.children.len() == 1 && sel.children[0].children.len() == 1 {
|
||||
if let ComplexSelectorChildren::CompoundSelector(sel) = &sel.children[0].children[0]
|
||||
{
|
||||
if sel.subclass_selectors.len() == 1 {
|
||||
if let SubclassSelector::Class(class_sel) = &sel.subclass_selectors[0] {
|
||||
if let Some(composes) = self.data.composes_for_current.take() {
|
||||
let composes = self.data.composes_for_current.take();
|
||||
|
||||
for child in &sel.children {
|
||||
if let ComplexSelectorChildren::CompoundSelector(sel) = &child.children[0] {
|
||||
for subclass_sel in &sel.subclass_selectors {
|
||||
if let SubclassSelector::Class(class_sel) = &subclass_sel {
|
||||
if let Some(composes) = &composes {
|
||||
let key = self
|
||||
.data
|
||||
.renamed_to_orig
|
||||
|
@ -0,0 +1,11 @@
|
||||
.__local__root-class {
|
||||
background-color: red;
|
||||
}
|
||||
.__local__chain-1,
|
||||
.__local__chain-2 {}
|
||||
.__local__chain-1 {
|
||||
color: blue;
|
||||
}
|
||||
.__local__chain-2 {
|
||||
color: green;
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
.root-class {
|
||||
background-color: red;
|
||||
}
|
||||
|
||||
.chain-1,
|
||||
.chain-2 {
|
||||
composes: root-class;
|
||||
}
|
||||
|
||||
.chain-1 {
|
||||
color: blue;
|
||||
}
|
||||
|
||||
.chain-2 {
|
||||
color: green;
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
{
|
||||
"root-class": [
|
||||
{
|
||||
"type": "local",
|
||||
"name": "__local__root-class"
|
||||
}
|
||||
],
|
||||
"chain-1": [
|
||||
{
|
||||
"type": "local",
|
||||
"name": "__local__chain-1"
|
||||
},
|
||||
{
|
||||
"type": "local",
|
||||
"name": "__local__root-class"
|
||||
}
|
||||
],
|
||||
"chain-2": [
|
||||
{
|
||||
"type": "local",
|
||||
"name": "__local__chain-2"
|
||||
},
|
||||
{
|
||||
"type": "local",
|
||||
"name": "__local__root-class"
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue
Block a user