Skip to content

Commit

Permalink
Update prefixSelector for latest selector parser
Browse files Browse the repository at this point in the history
  • Loading branch information
adamwathan committed Jan 14, 2019
1 parent 1a964bf commit 63c8793
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/util/prefixSelector.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import parser from 'postcss-selector-parser'
import get from 'lodash/get'

export default function(prefix, selector) {
const getPrefix = typeof prefix === 'function' ? prefix : () => prefix

return parser(selectors => {
selectors.walkClasses(classSelector => {
classSelector.value = `${getPrefix('.' + classSelector.value)}${classSelector.value}`
const baseClass = get(classSelector, 'raws.value', classSelector.value)

classSelector.setPropertyAndEscape(
'value',
`${getPrefix('.' + baseClass)}${baseClass}`
)
})
}).processSync(selector)
}

0 comments on commit 63c8793

Please sign in to comment.