Added Prefix Selector support via important config
This commit is contained in:
parent
c9bba9d1b1
commit
382075731d
6 changed files with 100 additions and 1 deletions
3
src/util/increaseSpecificity.js
Normal file
3
src/util/increaseSpecificity.js
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
export default function(importantVal, selector) {
|
||||
return `${importantVal} ${selector}`
|
||||
}
|
||||
|
|
@ -6,6 +6,7 @@ import generateVariantFunction from '../util/generateVariantFunction'
|
|||
import parseObjectStyles from '../util/parseObjectStyles'
|
||||
import prefixSelector from '../util/prefixSelector'
|
||||
import wrapWithVariants from '../util/wrapWithVariants'
|
||||
import increaseSpecificity from '../util/increaseSpecificity'
|
||||
|
||||
function parseStyles(styles) {
|
||||
if (!Array.isArray(styles)) {
|
||||
|
|
@ -55,7 +56,11 @@ export default function(plugins, config) {
|
|||
}
|
||||
|
||||
if (options.respectImportant && _.get(config, 'important')) {
|
||||
rule.walkDecls(decl => (decl.important = true))
|
||||
if (config.important === true) {
|
||||
rule.walkDecls(decl => (decl.important = true))
|
||||
} else if (typeof config.important === 'string') {
|
||||
rule.selector = increaseSpecificity(config.important, rule.selector)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue