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 e1d2764 commit 2b5358d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/util/prefixSelector.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
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 2b5358d

Please sign in to comment.