Skip to content

Commit f0e23c2

Browse files
dimitrinicolasjonathantneal
authored andcommitted
Fix an issue with tag/class/ids being extended oddly
1 parent 96d2382 commit f0e23c2

4 files changed

Lines changed: 31 additions & 1 deletion

File tree

.tape.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ module.exports = {
1717
},
1818
expect: 'basic.expect.css'
1919
},
20+
'basic.button': {
21+
message: 'supports @extend usage with same tag name and class name',
22+
expect: 'basic.button.expect.css'
23+
},
2024
'advanced': {
2125
message: 'supports mixed usage (with postcss-nesting)',
2226
plugin: () => require('postcss')(

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ function getSelectorIdMatch(selectorIds) {
138138
).join('|');
139139

140140
// selector unattached to an existing selector
141-
const selectorIdMatch = new RegExp(`(^|[^\\w-])(${escapedSelectorIds})([^\\w-]|$)`, '');
141+
const selectorIdMatch = new RegExp(`(^|[^\\w-]!\.!\#)(${escapedSelectorIds})([^\\w-]|$)`, '');
142142

143143
return selectorIdMatch;
144144
}

test/basic.button.css

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
button {
2+
color: red;
3+
}
4+
5+
.button {
6+
@extend button;
7+
background: blue;
8+
}
9+
10+
#button {
11+
@extend button;
12+
background: lime;
13+
}

test/basic.button.expect.css

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
button {
2+
color: red;
3+
}
4+
5+
.button {
6+
color: red;
7+
background: blue;
8+
}
9+
10+
#button {
11+
color: red;
12+
background: lime;
13+
}

0 commit comments

Comments
 (0)