Added Prefix Selector support via important config

This commit is contained in:
James Wee 2019-07-11 17:07:24 +12:00 • committed by James Wee
parent c9bba9d1b1
commit 382075731d
6 changed files with 100 additions and 1 deletions

View file

@ -0,0 +1,3 @@
export default function(importantVal, selector) {
return `${importantVal} ${selector}`
}

View file

@ -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)
}
}
})