fix(css/modules): Support composes when using multiple subclass selectors (#7949)

This commit is contained in:
Brandon Dail 2023-09-13 21:14:58 -05:00 committed by GitHub
parent 418a2e3016
commit 05ca19b844
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 62 additions and 7 deletions

View File

@ -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

View File

@ -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;
}

View File

@ -0,0 +1,16 @@
.root-class {
background-color: red;
}
.chain-1,
.chain-2 {
composes: root-class;
}
.chain-1 {
color: blue;
}
.chain-2 {
color: green;
}

View File

@ -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"
}
]
}