Use existing prefixSelector function
This commit is contained in:
parent
d7d715a94e
commit
39ec3b14cc
2 changed files with 28 additions and 1 deletions
|
|
@ -216,3 +216,29 @@ test('you can apply utility classes without using the given prefix', () => {
|
|||
expect(result.warnings().length).toBe(0)
|
||||
})
|
||||
})
|
||||
|
||||
// test('you can apply utility classes without using the given prefix when using a function for the prefix', () => {
|
||||
// const input = `
|
||||
// .foo { @apply .tw-mt-4 .mb-4; }
|
||||
// `
|
||||
|
||||
// const expected = `
|
||||
// .foo { margin-top: 1rem; margin-bottom: 1rem; }
|
||||
// `
|
||||
|
||||
// const config = {
|
||||
// ...defaultConfig,
|
||||
// options: {
|
||||
// ...defaultConfig.options,
|
||||
// prefix: selector => {
|
||||
// return 'tw-'
|
||||
// },
|
||||
// },
|
||||
// experiments: { shadowLookup: true },
|
||||
// }
|
||||
|
||||
// return run(input, config, generateUtilities(config, [])).then(result => {
|
||||
// expect(result.css).toEqual(expected)
|
||||
// expect(result.warnings().length).toBe(0)
|
||||
// })
|
||||
// })
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import _ from 'lodash'
|
||||
import postcss from 'postcss'
|
||||
import escapeClassName from '../util/escapeClassName'
|
||||
import prefixSelector from '../util/prefixSelector'
|
||||
|
||||
function buildClassTable(css) {
|
||||
const classTable = {}
|
||||
|
|
@ -35,7 +36,7 @@ function findClass(classToApply, classTable, shadowLookup, prefix, onError) {
|
|||
if (_.isEmpty(matches)) {
|
||||
if (_.isEmpty(shadowLookup)) {
|
||||
if (prefix) {
|
||||
classToApply = '.' + prefix + classToApply.substr(1)
|
||||
classToApply = prefixSelector(prefix, classToApply)
|
||||
matches = _.get(classTable, classToApply, [])
|
||||
if (_.isEmpty(matches)) {
|
||||
if (_.isEmpty(shadowLookup)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue