-
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,12 @@ function increaseSpecifityOfRule(rule, opts) { | |
) { | ||
return selector + opts.stackableRoot.repeat(opts.repeat); | ||
} | ||
|
||
// Avoid prefix for :exports since :export block defines the symbols | ||
// 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Done, test added |
||
|
||
// Otherwise just make it a descendant (this is what will happen most of the time) | ||
// `:not(#\\9):not(#\\9):not(#\\9) .foo` | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
:not(#\9):not(#\9):not(#\9) [id="foo"] { | ||
background: #f00 !important; | ||
} | ||
|
||
:not(#\9):not(#\9):not(#\9) [id^="bar"] { | ||
background: #0f0 !important; | ||
} | ||
|
||
:not(#\9):not(#\9):not(#\9) .foo { | ||
background: #f00; | ||
} | ||
|
||
:export { | ||
listColor: red; | ||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,15 @@ | ||||||||||||||||
[id="foo"] { | ||||||||||||||||
background: #f00; | ||||||||||||||||
} | ||||||||||||||||
|
||||||||||||||||
[id^="bar"] { | ||||||||||||||||
background: #0f0; | ||||||||||||||||
} | ||||||||||||||||
|
||||||||||||||||
Comment on lines
+1
to
+8
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can assert the same functionality with just the
Suggested change
|
||||||||||||||||
.foo { | ||||||||||||||||
background: #f00; | ||||||||||||||||
} | ||||||||||||||||
|
||||||||||||||||
:export { | ||||||||||||||||
listColor: red; | ||||||||||||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we need to use the |
||
}); | ||
}); |
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.