-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid prefixing :export for css modules #25
base: master
Are you sure you want to change the base?
Conversation
Avoid prefix for :export since :export block defines the symbols that are going to be exported to the consumer. It can be thought of functionally equivalent to the module.export
This was causing issues with export since it was prefixing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add tests
// that are going to be exported to the consumer | ||
if (selector.indexOf(":export") !== -1) { | ||
return selector; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems fine to me. But let's add a test for this case so we don't regress on this in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, test added
Thanks for the contribution @michelfrf. Looking good so far 🌵 |
The test was added let me know if you are happy with the changes. |
// Avoid prefix for :exports since :export block defines the symbols | ||
// that are going to be exported to the consumer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Avoid prefix for :exports since :export block defines the symbols | |
// that are going to be exported to the consumer | |
// Avoid prefix for `:export` blocks because they define the symbols | |
// that are going to be exported to the consumer, | |
// https://github.com/css-modules/icss#export |
[id="foo"] { | ||
background: #f00; | ||
} | ||
|
||
[id^="bar"] { | ||
background: #0f0; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can assert the same functionality with just the .foo
and :export
rules or maybe just :export
by itself
[id="foo"] { | |
background: #f00; | |
} | |
[id^="bar"] { | |
background: #0f0; | |
} |
@@ -119,4 +119,8 @@ describe('postcss-increase-specificity', function() { | |||
it('should not change the descendant rules of @keyframes', function() { | |||
return testPlugin('./test/fixtures/keyframes.css', './test/fixtures/keyframes.expected.css'); | |||
}); | |||
|
|||
it('should ignore :export option used in scss files', function() { | |||
return testPlugin('./test/fixtures/scss/export-option.scss', './test/fixtures/scss/export-option.expected.scss'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need to use the scss
extension here. CSS modules seem like they also applies to .css
Avoid prefix for
:export
since:export
block defines the symbols that are going to be exported to the consumer. It can be thought of functionally equivalent to the module.export