Skip to content

Commit

Permalink
Fix an issue with tag/class/ids being extended oddly
Browse files Browse the repository at this point in the history
  • Loading branch information
dimitrinicolas authored and jonathantneal committed Aug 10, 2018
1 parent 96d2382 commit f0e23c2
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .tape.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ module.exports = {
},
expect: 'basic.expect.css'
},
'basic.button': {
message: 'supports @extend usage with same tag name and class name',
expect: 'basic.button.expect.css'
},
'advanced': {
message: 'supports mixed usage (with postcss-nesting)',
plugin: () => require('postcss')(
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ function getSelectorIdMatch(selectorIds) {
).join('|');

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

return selectorIdMatch;
}
13 changes: 13 additions & 0 deletions test/basic.button.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
button {
color: red;
}

.button {
@extend button;
background: blue;
}

#button {
@extend button;
background: lime;
}
13 changes: 13 additions & 0 deletions test/basic.button.expect.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
button {
color: red;
}

.button {
color: red;
background: blue;
}

#button {
color: red;
background: lime;
}

0 comments on commit f0e23c2

Please sign in to comment.