Skip to content

Commit db85b72

Browse files
Adam Simpsonasimpson
authored andcommitted
🐛 account for doubly nested "brand" mixins
1 parent 3512256 commit db85b72

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

parseSCSS.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ const parser = (css) => {
1313
const parseAtRule = (at) => {
1414
if (/brand/.test(at.params)) {
1515
if (at.parent.type === 'atrule') {
16-
splits.push(`@${at.parent.name} ${at.parent.params} {`);
17-
splits.push(at.toString());
18-
splits.push('}');
16+
if (!/brand/.test(at.parent.params)) {
17+
splits.push(`@${at.parent.name} ${at.parent.params} {`);
18+
splits.push(at.toString());
19+
splits.push('}');
20+
}
1921
} else {
2022
splits.push(`${at.parent.selector} {`);
2123
splits.push(at.toString());

specs/index.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,21 @@ div {
9393
expect(x.splits[1]).to.equal('div span span { color: brand-color(c4); }');
9494
});
9595
});
96+
97+
it('does not unwrap doubly nested brand mixins', function () {
98+
const sassString = `
99+
body {
100+
margin: 0;
101+
102+
@include brand(foo) {
103+
@include brand-text();
104+
}
105+
}
106+
`;
107+
const parsed = parse(sassString);
108+
109+
parsed.then(x => {
110+
expect(x.splits[1]).to.equal('@include brand(mozo) {\n @include brand-text();\n }');
111+
});
112+
});
96113
});

0 commit comments

Comments
 (0)